refacto tinfoil
All checks were successful
dl / lint (push) Successful in 1m34s
dl / docker (push) Successful in 47s

This commit is contained in:
Michel Roux 2023-09-12 09:00:29 +02:00
parent 67f41f4658
commit 0b6c9e21a1

View File

@ -9,41 +9,19 @@ import requests
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-r", "--remote", type=str, required=True) parser.add_argument("-r", "--remote", type=str, required=True)
parser.add_argument("-f", "--force", action=argparse.BooleanOptionalAction)
args = parser.parse_args() args = parser.parse_args()
remote = args.remote remote = args.remote
force = args.force
req_titles = requests.get(
"https://raw.githubusercontent.com/blawar/titledb/master/FR.fr.json"
)
json_titles = req_titles.json()
titles = []
for json_title in json_titles:
titles.append(json_titles[json_title]["id"])
print("Titles OK")
proc_bases = subprocess.run( def drive_list(path):
["rclone", "lsf", f"{remote}:nsz/base"], proc = subprocess.run(
["rclone", "lsf", f"{remote}:{path}"],
check=True, check=True,
capture_output=True, capture_output=True,
) )
bases = proc_bases.stdout.decode().split("\n") return proc.stdout.decode().split("\n")
print("Base OK")
proc_dlcs = subprocess.run(
["rclone", "lsf", f"{remote}:nsz/dlc"],
check=True,
capture_output=True,
)
dlcs = proc_dlcs.stdout.decode().split("\n")
print("DLC OK")
proc_updates = subprocess.run(
["rclone", "lsf", f"{remote}:nsz/updates"],
check=True,
capture_output=True,
)
updates = proc_updates.stdout.decode().split("\n")
print("Updates OK")
def download(path, file): def download(path, file):
@ -57,6 +35,25 @@ def download(path, file):
) )
req_titles = requests.get(
"https://raw.githubusercontent.com/blawar/titledb/master/FR.fr.json"
)
json_titles = req_titles.json()
titles = []
for json_title in json_titles:
titles.append(json_titles[json_title]["id"])
print("Titles OK")
bases = drive_list("nsz/base")
print("Base OK")
dlcs = drive_list("nsz/dlc")
print("DLC OK")
updates = drive_list("nsz/updates")
print("Updates OK")
for base in bases: for base in bases:
re_id = re.search(r"\[([0-9A-F]*)\]", base) re_id = re.search(r"\[([0-9A-F]*)\]", base)
@ -65,7 +62,7 @@ for base in bases:
id = re_id.group(1) id = re_id.group(1)
if id not in titles: if not force and id not in titles:
continue continue
id = id[0:-4] id = id[0:-4]