From 1ef87c84da36389e1f61b63cf4a518bc4a125c80 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Fri, 23 Feb 2024 02:17:02 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20Add=20logs=20and=20test=20if=20l?= =?UTF-8?q?ogo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/retro.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/commands/retro.py b/commands/retro.py index 975c949..4bfe55d 100644 --- a/commands/retro.py +++ b/commands/retro.py @@ -26,9 +26,11 @@ for console in path.iterdir(): if console.is_dir() and Path(console / "roms").is_dir(): # cleaning logos for logo in Path(console / "logos").iterdir(): + print(f"Unlink {logo}") logo.unlink() # cleaning videos for video in Path(console / "videos").iterdir(): + print(f"Unlink {video}") video.unlink() # run has_files @@ -50,20 +52,24 @@ for console in path.iterdir(): # get rom ref for id in metadatas: - if rom.name in metadatas[id]["name"]: + if rom.name in metadatas[id]["name"] and ( + "ref" in metadatas[id] or "logo" in metadatas[id] + ): ref = metadatas[id]["ref"] if "ref" in metadatas[id] else id + print(f"Found {ref} for {rom}") + + # load json or create empty object + if paths["metadata"].is_file(): + with open(paths["metadata"], "r") as file: + meta = load(file) + else: + meta = {} + + # add rom to json + meta[hash] = {"ref": ref} + + # write json + with open(paths["metadata"], "w") as file: + file.write(meta) + break - - # load json or create empty object - if paths["metadata"].is_file(): - with open(paths["metadata"], "r") as file: - meta = load(file) - else: - meta = {} - - # add rom to json - meta[hash] = {"ref": ref} - - # write json - with open(paths["metadata"], "w") as file: - file.write(meta)