Fix resources dl for melee

master
Lertsenem 2021-07-23 19:44:45 +02:00
parent 18a4b6674e
commit 1fc572debe
2 changed files with 23 additions and 15 deletions

View File

@ -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",
],
},
),

View File

@ -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))