Changed how the Title ID is handled in Tickets, stubbed out NUS endpoint validation

This commit is contained in:
Campbell 2025-02-10 13:36:39 -05:00
parent 93abad1f31
commit 5dde9f7835
Signed by: NinjaCheetah
GPG Key ID: B547958AF96ED344
2 changed files with 12 additions and 9 deletions

View File

@ -315,9 +315,10 @@ def _validate_endpoint(endpoint: str) -> str:
The validated NUS endpoint with the proper path.
"""
# Find the root of the URL and then assemble the correct URL based on that.
new_url = _urlparse(endpoint)
if new_url.netloc == "":
endpoint_url = "http://" + new_url.path + "/ccs/download/"
else:
endpoint_url = "http://" + new_url.netloc + "/ccs/download/"
return endpoint_url
# TODO: Rewrite in a way that makes more sense and un-stub
#new_url = _urlparse(endpoint)
#if new_url.netloc == "":
# endpoint_url = "http://" + new_url.path + "/ccs/download/"
#else:
# endpoint_url = "http://" + new_url.netloc + "/ccs/download/"
return endpoint

View File

@ -128,7 +128,7 @@ class Ticket:
self.console_id = int.from_bytes(ticket_data.read(4))
# Title ID.
ticket_data.seek(0x1DC)
self.title_id = binascii.hexlify(ticket_data.read(8))
self.title_id = ticket_data.read(8)
# Unknown data 1.
ticket_data.seek(0x1E4)
self.unknown1 = ticket_data.read(2)
@ -202,7 +202,7 @@ class Ticket:
# Console ID.
ticket_data += int.to_bytes(self.console_id, 4)
# Title ID.
ticket_data += binascii.unhexlify(self.title_id)
ticket_data += self.title_id
# Unknown data 1.
ticket_data += self.unknown1
# Title version.
@ -318,6 +318,8 @@ class Ticket:
return "Korean"
case 2:
return "vWii"
case _:
return "Unknown"
def get_title_key(self) -> bytes:
"""
@ -343,7 +345,7 @@ class Ticket:
"""
if len(title_id) != 16:
raise ValueError("Invalid Title ID! Title IDs must be 8 bytes long.")
self.title_id = title_id.encode()
self.title_id = binascii.unhexlify(title_id.encode())
def set_title_version(self, new_version: str | int) -> None:
"""