From e4a8eba6992f398fd08dc7a58bb8eedd4d4f66b7 Mon Sep 17 00:00:00 2001 From: GitBluub Date: Wed, 15 Nov 2023 13:08:16 +0100 Subject: [PATCH] feat: gen cover in populate wip --- assets/populate.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/assets/populate.py b/assets/populate.py index 4b06513..66225c8 100755 --- a/assets/populate.py +++ b/assets/populate.py @@ -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())