Added simple NUS downloading interface

This commit is contained in:
Campbell 2024-04-05 01:39:05 -04:00
parent c3111aaf7a
commit ceb7b38fa1
Signed by: NinjaCheetah
GPG Key ID: B547958AF96ED344
3 changed files with 32 additions and 1 deletions

10
main.py
View File

@ -3,6 +3,7 @@
import sys
from modules.wad import *
from modules.nus import *
opts = [opt for opt in sys.argv[1:] if opt.startswith("-")]
args = [arg for arg in sys.argv[1:] if not arg.startswith("-")]
@ -18,5 +19,14 @@ if __name__ == "__main__":
pack_wad_from_folder(args[1], args[2])
exit(0)
raise SystemExit(f"Usage: {sys.argv[0]} WAD (-u | -p) <input> <output>")
elif "NUS" in args:
if "-d" in opts:
if len(args) == 2:
download_title(args[1])
exit(0)
elif len(args) == 3:
download_title(args[1], args[2])
exit(0)
raise SystemExit(f"Usage: {sys.argv[0]} NUS -d <Title ID> <Title Version (Optional)>")
else:
raise SystemExit(f"Usage: {sys.argv[0]} WAD (-u | -p) <input> <output>")

22
modules/nus.py Normal file
View File

@ -0,0 +1,22 @@
# "nus.py" from libWiiPy-cli by NinjaCheetah
# https://github.com/NinjaCheetah/libWiiPy-cli
import libWiiPy
def download_title(title_id: str, title_version_input: str = None):
title_version = None
if title_version_input is not None:
try:
title_version = int(title_version_input)
except ValueError:
print("Enter a valid integer for the Title Version.")
return
title = libWiiPy.download_title(title_id, title_version)
file_name = title_id + "-v" + str(title.tmd.title_version) + ".wad"
wad_file = open(file_name, "wb")
wad_file.write(title.dump_wad())
wad_file.close()

View File

@ -1,2 +1 @@
git+https://github.com/NinjaCheetah/libWiiPy
pycryptodome