feat: gen cover in populate wip

This commit is contained in:
GitBluub
2023-11-15 13:08:16 +01:00
parent bfb6cf5958
commit e4a8eba699

View File

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