From f64c87732a2c7edd20715a815aa5261218e40049 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Mon, 11 Sep 2023 09:02:57 +0200 Subject: [PATCH] Use nsz base --- commands/tinfoil.py | 50 ++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/commands/tinfoil.py b/commands/tinfoil.py index a7b2ddc..72d90ec 100755 --- a/commands/tinfoil.py +++ b/commands/tinfoil.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import argparse +import os import re import subprocess import sys @@ -20,13 +21,13 @@ for json_title in json_titles: titles.append(json_titles[json_title]["id"]) print("Titles OK") -proc_xczs = subprocess.run( - ["rclone", "lsf", f"{remote}:xcz"], +proc_bases = subprocess.run( + ["rclone", "lsf", f"{remote}:nsz/base"], check=True, capture_output=True, ) -xczs = proc_xczs.stdout.decode().split("\n") -print("XCZ OK") +bases = proc_bases.stdout.decode().split("\n") +print("Base OK") proc_dlcs = subprocess.run( ["rclone", "lsf", f"{remote}:nsz/dlc"], @@ -44,8 +45,20 @@ proc_updates = subprocess.run( updates = proc_updates.stdout.decode().split("\n") print("Updates OK") -for xcz in xczs: - re_id = re.search(r"\[([0-9A-F]*)\]", xcz) + +def download(path, file): + if os.path.isfile(os.path.join(path, file)): + return + + subprocess.run( + ["rclone", "copy", "-P", "-v", f"{remote}:{path}/{base}", f"{path}/"], + check=True, + stdout=sys.stdout, + ) + + +for base in bases: + re_id = re.search(r"\[([0-9A-F]*)\]", base) if not re_id: continue @@ -57,31 +70,12 @@ for xcz in xczs: id = id[0:-4] - subprocess.run( - ["rclone", "copy", "-P", "-v", f"{remote}:xcz/{xcz}", "xcz/"], - stdout=sys.stdout, - check=True, - ) + download("nsz/base", base) for dlc in dlcs: if id in dlc: - subprocess.run( - ["rclone", "copy", "-P", "-v", f"{remote}:nsz/dlc/{dlc}", "nsz/dlc/"], - stdout=sys.stdout, - check=True, - ) + download("nsz/dlc", dlc) for update in updates: if id in update: - subprocess.run( - [ - "rclone", - "copy", - "-P", - "-v", - f"{remote}:nsz/updates/{update}", - "nsz/updates/", - ], - stdout=sys.stdout, - check=True, - ) + download("nsz/updates", update)