From 1fc572debe6aca62df565e3bc04785b3e9f4b3ac Mon Sep 17 00:00:00 2001 From: Lertsenem Date: Fri, 23 Jul 2021 19:44:45 +0200 Subject: [PATCH] Fix resources dl for melee --- lokrez/games/melee.py | 16 ++++++++-------- lokrez/resources.py | 22 +++++++++++++++------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/lokrez/games/melee.py b/lokrez/games/melee.py index b1b3704..f3b6788 100644 --- a/lokrez/games/melee.py +++ b/lokrez/games/melee.py @@ -46,10 +46,10 @@ EVERYONE = [ Character( smashggid = 4, name = "dr mario", - codenames = [ "doc", ], + codenames = [ "dr", "doc", ], res_urls = { "smashlyon": [ - "https://resources.smashlyon.com/melee/doc.zip", + "https://resources.smashlyon.com/melee/dr.zip", ], }, ), @@ -86,10 +86,10 @@ EVERYONE = [ Character( smashggid = 8, name = "ice climbers", - codenames = [ "iceclimber", ], + codenames = [ "ice", "iceclimber", ], res_urls = { "smashlyon": [ - "https://resources.smashlyon.com/melee/iceclimber.zip", + "https://resources.smashlyon.com/melee/ice.zip", ], }, ), @@ -246,10 +246,10 @@ EVERYONE = [ Character( smashggid = 25, name = "young link", - codenames = [ "yink", ], + codenames = [ "young", "yink", ], res_urls = { "smashlyon": [ - "https://resources.smashlyon.com/melee/yink.zip", + "https://resources.smashlyon.com/melee/young.zip", ], }, ), @@ -266,10 +266,10 @@ EVERYONE = [ Character( smashggid = None, name = "mr game and watch", - codenames = [ "mrgameandwatch", ], + codenames = [ "game", "mrgameandwatch", ], res_urls = { "smashlyon": [ - "https://resources.smashlyon.com/melee/mrgameandwatch.zip", + "https://resources.smashlyon.com/melee/game.zip", ], }, ), diff --git a/lokrez/resources.py b/lokrez/resources.py index 8788990..c83b51e 100644 --- a/lokrez/resources.py +++ b/lokrez/resources.py @@ -62,11 +62,13 @@ def download_res( # Select default source if needed if not source: - if game.GAME.name == "pplus": + if game.GAME.name in [ "pplus", "melee" ]: source = "smashlyon" elif game.GAME.name == "ssbu": source = "spriters" + log.info("Using default source {}".format(source)) + if source not in ["smashlyon", "spriters"]: raise NotImplementedError( "The only working sources are 'smashlyon' and 'spriters'", @@ -165,12 +167,17 @@ def download_res( # otherwise: get the characters pictures and write them in the # outdir with zipfile.ZipFile(f) as zf: - for source_filename in zf.namelist(): + for source_file in zf.filelist: + + if source_file.is_dir(): + continue + + source_filename = source_file.filename if "No Gamma Fix" in source_filename: continue - if not any(c in source_filename for c in characters.codenames): + if not any(c in source_filename for c in character.codenames): continue target_filename = pathlib.Path(source_filename).name @@ -180,10 +187,11 @@ def download_res( target_filename = pathlib.Path(source_filename).name - target_filename = target_filename.replace( - character.codenames[0], - character.name, - ) + for codename in character.codenames: + target_filename = target_filename.replace( + codename, + character.name, + ) log.debug("Writing file '{}'".format(target_filename))