build_clips builds clips
This commit is contained in:
parent
2c069d9852
commit
32c3a810b5
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
songbook.sqlite
|
||||
public/
|
||||
/songbook.sqlite
|
||||
/public/
|
||||
/clips/
|
||||
45
build_clips.py
Normal file
45
build_clips.py
Normal file
@ -0,0 +1,45 @@
|
||||
import sqlite3
|
||||
import os
|
||||
import glob
|
||||
import subprocess
|
||||
|
||||
os.removedirs('clips')
|
||||
os.mkdir('clips')
|
||||
|
||||
db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True)
|
||||
|
||||
cur = db.cursor()
|
||||
|
||||
for song, motif, start, duration in db.execute('''
|
||||
select
|
||||
song_id, motif_id, start_ms, duration_ms
|
||||
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()
|
||||
|
||||
# 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]
|
||||
|
||||
print(source)
|
||||
|
||||
# get clip filename
|
||||
|
||||
destination = f'clips/{song:04}-{motif:03}.flac'
|
||||
|
||||
print (destination)
|
||||
|
||||
# call sox
|
||||
|
||||
subprocess.run(["sox", source, destination, "trim", f'{start / 1000}', f'{duration / 1000}'], check = True)
|
||||
@ -13,7 +13,7 @@ for dirname in [
|
||||
environment = jinja2.Environment(loader=jinja2.FileSystemLoader("templates/"))
|
||||
songplate = environment.get_template("songpage.jinja")
|
||||
|
||||
db = sqlite3.connect("songbook.sqlite")
|
||||
db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True)
|
||||
|
||||
|
||||
for song in db.execute("SELECT name FROM song"):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user