Compare commits
No commits in common. "6880b57844fe6da5140772a01e87f99fb6f0ebfc" and "6a3216a25bd64529483387914a12cc69424c8e49" have entirely different histories.
6880b57844
...
6a3216a25b
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/songbook.sqlite
|
||||
/public/
|
||||
/clips/
|
||||
@ -4,40 +4,40 @@ import glob
|
||||
import shutil
|
||||
import sox
|
||||
|
||||
shutil.rmtree('public/clip')
|
||||
os.makedirs('public/clip', exist_ok=True)
|
||||
shutil.rmtree('clips')
|
||||
os.mkdir('clips')
|
||||
|
||||
db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True)
|
||||
|
||||
cur = db.cursor()
|
||||
|
||||
for song, motif, start, duration, album, track in db.execute('''
|
||||
for song, motif, start, duration in db.execute('''
|
||||
select
|
||||
clip.song_id, motif_id, start_ms, duration_ms, max(album_id), track
|
||||
song_id, motif_id, start_ms, duration_ms
|
||||
from
|
||||
clip'''):
|
||||
album, track = db.execute('''
|
||||
select
|
||||
album_id, track
|
||||
from
|
||||
clip
|
||||
join
|
||||
song_album
|
||||
on
|
||||
clip.song_id=song_album.song_id
|
||||
group by
|
||||
clip.song_id, motif_id'''
|
||||
):
|
||||
where
|
||||
song_id = ?
|
||||
order by
|
||||
album_id desc limit 1''', (song,)).fetchone()
|
||||
|
||||
# get source path
|
||||
|
||||
album_folder = f'{album - 1:02}. *'
|
||||
song_file = f'{track:03}. *.flac'
|
||||
|
||||
source = glob.glob(f"/mnt/petal/media/Audio/ffxiv/{album_folder}/{song_file}")
|
||||
assert(len(source) == 1)
|
||||
source = source[0]
|
||||
source = glob.glob(f"/mnt/petal/media/Audio/ffxiv/{album_folder}/{song_file}")[0]
|
||||
|
||||
print(source)
|
||||
|
||||
# get clip filename
|
||||
|
||||
destination = f'public/clip/{song:04}-{motif:03}.flac'
|
||||
destination = f'clips/{song:04}-{motif:03}.flac'
|
||||
|
||||
print(destination)
|
||||
|
||||
@ -45,23 +45,21 @@ for song, motif, start, duration, album, track in db.execute('''
|
||||
|
||||
# trim and fade start
|
||||
|
||||
fade_length = 2
|
||||
|
||||
if start < fade_length:
|
||||
if start < 2:
|
||||
trim_start = 0
|
||||
fade_in = 0
|
||||
else:
|
||||
trim_start = start - fade_length
|
||||
fade_in = fade_length
|
||||
trim_start = start - 2
|
||||
fade_in = 2
|
||||
|
||||
# trim and fade end (to be continued)
|
||||
|
||||
if source_duration - (start + duration ) < fade_length:
|
||||
if source_duration - (start + duration ) < 2:
|
||||
trim_end = None
|
||||
fade_out = 0
|
||||
else:
|
||||
trim_end = start + duration + fade_length
|
||||
fade_out = fade_length
|
||||
trim_end = start + duration + 2
|
||||
fade_out = 2
|
||||
|
||||
# call sox
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import sqlite3
|
||||
import jinja2
|
||||
import os
|
||||
import shutil
|
||||
|
||||
for dirname in [
|
||||
"public/song",
|
||||
"public/motif",
|
||||
"public/album"
|
||||
"public/album",
|
||||
"public/clip",
|
||||
]:
|
||||
os.makedirs(dirname, exist_ok=True)
|
||||
|
||||
@ -15,40 +15,21 @@ songplate = environment.get_template("songpage.jinja")
|
||||
|
||||
db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True)
|
||||
|
||||
# generate song pages
|
||||
|
||||
for id, name, name_jp in db.execute('''
|
||||
select
|
||||
id, name, name_jp
|
||||
from
|
||||
song
|
||||
'''):
|
||||
|
||||
# query album info
|
||||
|
||||
album_info = db.execute('''
|
||||
select
|
||||
album_id, track, album.name, album.code
|
||||
from
|
||||
song_album
|
||||
join
|
||||
album
|
||||
on
|
||||
song_album.album_id=album.id
|
||||
where
|
||||
song_id = ?
|
||||
''',
|
||||
(id,)
|
||||
).fetchall()
|
||||
|
||||
print(album_info)
|
||||
|
||||
filename = f"public/song/{id:04}"
|
||||
for song in db.execute("SELECT name FROM song"):
|
||||
filename = f"public/song/{song[0]}"
|
||||
content = songplate.render(
|
||||
name=name,
|
||||
id=id,
|
||||
album_info=album_info
|
||||
songname=song[0],
|
||||
clips=()
|
||||
)
|
||||
with open(filename, mode="w") as file:
|
||||
file.write(content)
|
||||
print(f"... wrote {filename}")
|
||||
|
||||
# template = environment.from_string("Now Playing: {{ song }}")
|
||||
# for songname in songnames:
|
||||
# print(
|
||||
# template.render(
|
||||
# song=songname[0]
|
||||
# )
|
||||
# )
|
||||
@ -1,2 +0,0 @@
|
||||
sudo rm -r /var/www/eorzea-songbook
|
||||
sudo cp -r public/ /var/www/eorzea-songbook
|
||||
12
notes.txt
12
notes.txt
@ -1,12 +0,0 @@
|
||||
eorzea-songbook.com/
|
||||
|
||||
index.html
|
||||
|
||||
/song
|
||||
/name
|
||||
|
||||
/motif
|
||||
/name
|
||||
|
||||
/album
|
||||
/name
|
||||
@ -7,15 +7,7 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Now Playing: {{ id }}. {{ name }} ({% for _, _, _, album_code in album_info %}{{ album_code }}{% if not loop.last %}, {% endif %}{% endfor %})
|
||||
</h1>
|
||||
<p>Artist: </p>
|
||||
<p>Album: </p>
|
||||
<ul>
|
||||
{% for album_id, track, album_name, album_code in album_info %}
|
||||
<li>{{ album_name }} #{{ track }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<p>Clips: </p>
|
||||
<h1>Now Playing: {{ songname }}</h1>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user