add tinfoil command
This commit is contained in:
parent
edcddcef62
commit
0124b79d65
78
commands/tinfoil.py
Executable file
78
commands/tinfoil.py
Executable file
@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import requests
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-r", "--remote", type=str)
|
||||
args = parser.parse_args()
|
||||
|
||||
remote = args.remote
|
||||
|
||||
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_xczs = subprocess.run(
|
||||
["rclone", "lsf", f"{remote}:xcz"],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
xczs = proc_xczs.stdout.decode().split("\n")
|
||||
print("XCZ 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")
|
||||
|
||||
for xcz in xczs:
|
||||
re_id = re.search(r"\[([0-9A-F]*)\]", xcz)
|
||||
|
||||
if not re_id:
|
||||
continue
|
||||
|
||||
id = re_id.group(1)
|
||||
|
||||
if id not in titles:
|
||||
continue
|
||||
|
||||
id = id[0:-3]
|
||||
|
||||
subprocess.run(
|
||||
["rclone", "copy", "-P", f"{remote}:xcz/{xcz}", "xcz/"],
|
||||
stdout=sys.stdout,
|
||||
)
|
||||
|
||||
for dlc in dlcs:
|
||||
if id in dlc:
|
||||
subprocess.run(
|
||||
["rclone", "copy", "-P", f"{remote}:nsz/dlc/{dlc}", "nsz/dlc/"],
|
||||
stdout=sys.stdout,
|
||||
)
|
||||
|
||||
for update in updates:
|
||||
if id in update:
|
||||
subprocess.run(
|
||||
["rclone", "copy", "-P", f"{remote}:nsz/updates/{dlc}", "nsz/updates/"],
|
||||
stdout=sys.stdout,
|
||||
)
|
Loading…
Reference in New Issue
Block a user