From 8599c43c2d6193bbbd541d77b987b339547f87a7 Mon Sep 17 00:00:00 2001 From: NinjaCheetah <58050615+NinjaCheetah@users.noreply.github.com> Date: Wed, 10 Jul 2024 21:59:02 +1000 Subject: [PATCH] Change content subcommand to use 000000xx formatting for CID --- modules/nus.py | 11 +++++++---- wiipy.py | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/nus.py b/modules/nus.py index bd0d292..0fd645d 100644 --- a/modules/nus.py +++ b/modules/nus.py @@ -4,6 +4,7 @@ import os import hashlib import pathlib +import binascii import libWiiPy @@ -146,11 +147,13 @@ def handle_nus_content(args): else: decrypt_content = False - content_file_name = hex(cid)[2:] + content_id = int.from_bytes(binascii.unhexlify(cid)) + + content_file_name = hex(content_id)[2:] while len(content_file_name) < 8: content_file_name = "0" + content_file_name - content_data = libWiiPy.title.download_content(tid, cid) + content_data = libWiiPy.title.download_content(tid, content_id) if decrypt_content is True: content_file_name = content_file_name + ".app" @@ -167,7 +170,7 @@ def handle_nus_content(args): content_size = 0 content_index = 0 for record in tmd.content_records: - if record.content_id == cid: + if record.content_id == content_id: content_hash = record.content_hash.decode() content_size = record.content_size content_index = record.index @@ -186,4 +189,4 @@ def handle_nus_content(args): file.write(content_data) file.close() - print("Downloaded content with Content ID \"" + str(cid) + "\"!") + print("Downloaded content with Content ID \"" + cid + "\"!") diff --git a/wiipy.py b/wiipy.py index be58790..7b00388 100644 --- a/wiipy.py +++ b/wiipy.py @@ -53,7 +53,8 @@ if __name__ == "__main__": description="download a specific content from the NUS") nus_content_parser.set_defaults(func=handle_nus_content) nus_content_parser.add_argument("tid", metavar="TID", type=str, help="Title ID the content belongs to") - nus_content_parser.add_argument("cid", metavar="CID", type=int, help="Content ID to download") + nus_content_parser.add_argument("cid", metavar="CID", type=str, + help="Content ID to download (in \"000000xx\" format)") nus_content_parser.add_argument("-v", "--version", metavar="VERSION", type=int, help="version this content belongs to (required for decryption)") nus_content_parser.add_argument("-d", "--decrypt", action="store_true", help="decrypt this content")