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. The validated NUS endpoint with the proper path.
""" """
# Find the root of the URL and then assemble the correct URL based on that. # Find the root of the URL and then assemble the correct URL based on that.
new_url = _urlparse(endpoint) # TODO: Rewrite in a way that makes more sense and un-stub
if new_url.netloc == "": #new_url = _urlparse(endpoint)
endpoint_url = "http://" + new_url.path + "/ccs/download/" #if new_url.netloc == "":
else: # endpoint_url = "http://" + new_url.path + "/ccs/download/"
endpoint_url = "http://" + new_url.netloc + "/ccs/download/" #else:
return endpoint_url # 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)) self.console_id = int.from_bytes(ticket_data.read(4))
# Title ID. # Title ID.
ticket_data.seek(0x1DC) ticket_data.seek(0x1DC)
self.title_id = binascii.hexlify(ticket_data.read(8)) self.title_id = ticket_data.read(8)
# Unknown data 1. # Unknown data 1.
ticket_data.seek(0x1E4) ticket_data.seek(0x1E4)
self.unknown1 = ticket_data.read(2) self.unknown1 = ticket_data.read(2)
@ -202,7 +202,7 @@ class Ticket:
# Console ID. # Console ID.
ticket_data += int.to_bytes(self.console_id, 4) ticket_data += int.to_bytes(self.console_id, 4)
# Title ID. # Title ID.
ticket_data += binascii.unhexlify(self.title_id) ticket_data += self.title_id
# Unknown data 1. # Unknown data 1.
ticket_data += self.unknown1 ticket_data += self.unknown1
# Title version. # Title version.
@ -318,6 +318,8 @@ class Ticket:
return "Korean" return "Korean"
case 2: case 2:
return "vWii" return "vWii"
case _:
return "Unknown"
def get_title_key(self) -> bytes: def get_title_key(self) -> bytes:
""" """
@ -343,7 +345,7 @@ class Ticket:
""" """
if len(title_id) != 16: if len(title_id) != 16:
raise ValueError("Invalid Title ID! Title IDs must be 8 bytes long.") 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: def set_title_version(self, new_version: str | int) -> None:
""" """