35 lines
817 B
Python
35 lines
817 B
Python
import sqlite3
|
|
import jinja2
|
|
import os
|
|
|
|
for dirname in [
|
|
"public/song",
|
|
"public/motif",
|
|
"public/album",
|
|
"public/clip",
|
|
]:
|
|
os.makedirs(dirname, exist_ok=True)
|
|
|
|
environment = jinja2.Environment(loader=jinja2.FileSystemLoader("templates/"))
|
|
songplate = environment.get_template("songpage.jinja")
|
|
|
|
db = sqlite3.connect("songbook.sqlite")
|
|
|
|
|
|
for song in db.execute("SELECT name FROM song"):
|
|
filename = f"public/song/{song[0]}"
|
|
content = songplate.render(
|
|
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]
|
|
# )
|
|
# ) |