From af864972ed8ab8886613653772f568eb4b58fbd8 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 3 Oct 2023 18:52:59 +0200 Subject: [PATCH] fix remove (again) --- commands/tinfoil.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/commands/tinfoil.py b/commands/tinfoil.py index eb6c9db..d898f82 100755 --- a/commands/tinfoil.py +++ b/commands/tinfoil.py @@ -67,13 +67,14 @@ updates = drive_list("nsz/updates") print("Updates OK") -def get_title_shortid(name): +def get_title_fullid(name): re_id = re.search(r"\[([0-9A-F]*)\]", name) - if not re_id: - return + return re_id.group(1) if re_id else None - id = re_id.group(1) + +def get_title_shortid(name): + id = get_title_fullid(name) return id[0:-4] if id in titles else None @@ -89,21 +90,27 @@ except subprocess.CalledProcessError: for base in bases: - id = get_title_shortid(base) + shortid = get_title_shortid(base) - if id: + if shortid: download("nsz/base", base) + + for dlc in dlcs: + if shortid in dlc: + download("nsz/dlc", dlc) + + for update in updates: + if shortid in update: + download("nsz/updates", update) else: remove("nsz/base", base) - for dlc in dlcs: - if id in dlc: - download("nsz/dlc", dlc) - else: - remove("nsz/dlc", dlc) + fullid = get_title_fullid(base) - for update in updates: - if id in update: - download("nsz/updates", update) - else: - remove("nsz/updates", update) + for dlc in dlcs: + if fullid in dlc: + remove("nsz/dlc", dlc) + + for update in updates: + if fullid in update: + remove("nsz/updates", update)