mirror of
https://github.com/NinjaCheetah/WiiPy.git
synced 2025-06-29 07:31:02 -04:00
Change content subcommand to use 000000xx formatting for CID
This commit is contained in:
parent
1b603e94fc
commit
8599c43c2d
@ -4,6 +4,7 @@
|
|||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import binascii
|
||||||
import libWiiPy
|
import libWiiPy
|
||||||
|
|
||||||
|
|
||||||
@ -146,11 +147,13 @@ def handle_nus_content(args):
|
|||||||
else:
|
else:
|
||||||
decrypt_content = False
|
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:
|
while len(content_file_name) < 8:
|
||||||
content_file_name = "0" + content_file_name
|
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:
|
if decrypt_content is True:
|
||||||
content_file_name = content_file_name + ".app"
|
content_file_name = content_file_name + ".app"
|
||||||
@ -167,7 +170,7 @@ def handle_nus_content(args):
|
|||||||
content_size = 0
|
content_size = 0
|
||||||
content_index = 0
|
content_index = 0
|
||||||
for record in tmd.content_records:
|
for record in tmd.content_records:
|
||||||
if record.content_id == cid:
|
if record.content_id == content_id:
|
||||||
content_hash = record.content_hash.decode()
|
content_hash = record.content_hash.decode()
|
||||||
content_size = record.content_size
|
content_size = record.content_size
|
||||||
content_index = record.index
|
content_index = record.index
|
||||||
@ -186,4 +189,4 @@ def handle_nus_content(args):
|
|||||||
file.write(content_data)
|
file.write(content_data)
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
print("Downloaded content with Content ID \"" + str(cid) + "\"!")
|
print("Downloaded content with Content ID \"" + cid + "\"!")
|
||||||
|
3
wiipy.py
3
wiipy.py
@ -53,7 +53,8 @@ if __name__ == "__main__":
|
|||||||
description="download a specific content from the NUS")
|
description="download a specific content from the NUS")
|
||||||
nus_content_parser.set_defaults(func=handle_nus_content)
|
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("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,
|
nus_content_parser.add_argument("-v", "--version", metavar="VERSION", type=int,
|
||||||
help="version this content belongs to (required for decryption)")
|
help="version this content belongs to (required for decryption)")
|
||||||
nus_content_parser.add_argument("-d", "--decrypt", action="store_true", help="decrypt this content")
|
nus_content_parser.add_argument("-d", "--decrypt", action="store_true", help="decrypt this content")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user