mirror of
https://github.com/NinjaCheetah/WiiPy.git
synced 2026-02-17 02:25:39 -05:00
Added support for specifying an output path for NUS downloads
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
# "nus.py" from WiiPy by NinjaCheetah
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import pathlib
|
||||
import libWiiPy
|
||||
|
||||
|
||||
def handle_nus(args):
|
||||
title_version = None
|
||||
file_path = None
|
||||
|
||||
# Check if --version was passed, because it'll be None if it wasn't.
|
||||
if args.version is not None:
|
||||
@@ -15,12 +17,23 @@ def handle_nus(args):
|
||||
print("Enter a valid integer for the Title Version.")
|
||||
return
|
||||
|
||||
# If --output was passed, then save the file to the specified path (as long as it's valid).
|
||||
if args.output is not None:
|
||||
file_path = pathlib.Path(args.output)
|
||||
if not file_path.parent.exists() or not file_path.parent.is_dir():
|
||||
print("The specified output path does not exist!")
|
||||
return
|
||||
if file_path.suffix != ".wad":
|
||||
file_path = file_path.with_suffix(".wad")
|
||||
|
||||
# libWiiPy accepts a title version of "None" and will just use the latest available version if it gets it.
|
||||
title = libWiiPy.title.download_title(args.tid, title_version)
|
||||
|
||||
file_name = args.tid + "-v" + str(title.tmd.title_version) + ".wad"
|
||||
# If we haven't gotten a name yet, make one from the TID and version.
|
||||
if file_path is None:
|
||||
file_path = pathlib.Path(args.tid + "-v" + str(title.tmd.title_version) + ".wad")
|
||||
|
||||
wad_file = open(file_name, "wb")
|
||||
wad_file = open(file_path, "wb")
|
||||
wad_file.write(title.dump_wad())
|
||||
wad_file.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user