diff --git a/.gitignore b/.gitignore index 789d5f1..33ed238 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ /songbook.sqlite -/public/ -/clips/ \ No newline at end of file +/public/ \ No newline at end of file diff --git a/build_clips.py b/build_clips.py index 3544db5..1dc6a06 100644 --- a/build_clips.py +++ b/build_clips.py @@ -4,40 +4,40 @@ import glob import shutil import sox -shutil.rmtree('clips') -os.mkdir('clips') +shutil.rmtree('public/clip') +os.makedirs('public/clip', exist_ok=True) db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True) cur = db.cursor() -for song, motif, start, duration in db.execute(''' +for song, motif, start, duration, album, track in db.execute(''' select - song_id, motif_id, start_ms, duration_ms + clip.song_id, motif_id, start_ms, duration_ms, max(album_id), track from - clip'''): - album, track = db.execute(''' - select - album_id, track - from - song_album - where - song_id = ? - order by - album_id desc limit 1''', (song,)).fetchone() + clip + join + song_album + on + clip.song_id=song_album.song_id + group by + clip.song_id, motif_id''' + ): # 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}")[0] + source = glob.glob(f"/mnt/petal/media/Audio/ffxiv/{album_folder}/{song_file}") + assert(len(source) == 1) + source = source[0] print(source) # get clip filename - destination = f'clips/{song:04}-{motif:03}.flac' + destination = f'public/clip/{song:04}-{motif:03}.flac' print(destination) @@ -45,21 +45,23 @@ for song, motif, start, duration in db.execute(''' # trim and fade start - if start < 2: + fade_length = 2 + + if start < fade_length: trim_start = 0 fade_in = 0 else: - trim_start = start - 2 - fade_in = 2 + trim_start = start - fade_length + fade_in = fade_length # trim and fade end (to be continued) - if source_duration - (start + duration ) < 2: + if source_duration - (start + duration ) < fade_length: trim_end = None fade_out = 0 else: - trim_end = start + duration + 2 - fade_out = 2 + trim_end = start + duration + fade_length + fade_out = fade_length # call sox diff --git a/build_pages.py b/build_pages.py index 04df5d1..b74da2c 100644 --- a/build_pages.py +++ b/build_pages.py @@ -6,7 +6,6 @@ for dirname in [ "public/song", "public/motif", "public/album", - "public/clip", ]: os.makedirs(dirname, exist_ok=True) diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..9a644e7 --- /dev/null +++ b/notes.txt @@ -0,0 +1,12 @@ +eorzea-songbook.com/ + +index.html + +/song + /name + +/motif + /name + +/album + /name \ No newline at end of file