1 Commits

Author SHA1 Message Date
GitBluub
e4a8eba699 feat: gen cover in populate wip 2023-11-15 13:08:16 +01:00

View File

@@ -40,10 +40,16 @@ def getOrCreateArtist(name):
print(out) print(out)
return out["id"] return out["id"]
def gen_cover():
def populateFile(path, midi, mxl): def populateFile(path, midi, mxl):
config = ConfigParser() config = ConfigParser()
config.read(path) config.read(path)
mid = MidiFile(midi) mid = MidiFile(midi)
common = os.path.commonpath([midi, mxl])
png_path = f"{common}/illustration.png"
if not os.path.exists(png_path):
gen_cover(common)
metadata = config["Metadata"]; metadata = config["Metadata"];
difficulties = dict(config["Difficulties"]) difficulties = dict(config["Difficulties"])
difficulties["length"] = round((mid.length), 2) difficulties["length"] = round((mid.length), 2)
@@ -57,7 +63,7 @@ def populateFile(path, midi, mxl):
"artist": artistId, "artist": artistId,
"album": getOrCreateAlbum(metadata["Album"], artistId), "album": getOrCreateAlbum(metadata["Album"], artistId),
"genre": getOrCreateGenre(metadata["Genre"]), "genre": getOrCreateGenre(metadata["Genre"]),
"illustrationPath": f"/assets/{os.path.commonpath([midi, mxl])}/illustration.png" "illustrationPath": f"/assets/{png_path}"
}) })
print(res.json()) print(res.json())