refacto tinfoil
This commit is contained in:
parent
67f41f4658
commit
0b6c9e21a1
@ -9,41 +9,19 @@ import requests
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-r", "--remote", type=str, required=True)
|
||||
parser.add_argument("-f", "--force", action=argparse.BooleanOptionalAction)
|
||||
args = parser.parse_args()
|
||||
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(
|
||||
["rclone", "lsf", f"{remote}:nsz/base"],
|
||||
def drive_list(path):
|
||||
proc = subprocess.run(
|
||||
["rclone", "lsf", f"{remote}:{path}"],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
bases = proc_bases.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")
|
||||
)
|
||||
return proc.stdout.decode().split("\n")
|
||||
|
||||
|
||||
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:
|
||||
re_id = re.search(r"\[([0-9A-F]*)\]", base)
|
||||
|
||||
@ -65,7 +62,7 @@ for base in bases:
|
||||
|
||||
id = re_id.group(1)
|
||||
|
||||
if id not in titles:
|
||||
if not force and id not in titles:
|
||||
continue
|
||||
|
||||
id = id[0:-4]
|
||||
|
Loading…
Reference in New Issue
Block a user