mirror of
https://github.com/NinjaCheetah/libWiiPy.git
synced 2025-06-07 22:11:00 -04:00
Compare commits
No commits in common. "f0b79e1f39092e6400126f79b9312ac4fe936b63" and "47472e7b94e40b7431af3ef11dbcac87b9dcbabd" have entirely different histories.
f0b79e1f39
...
47472e7b94
@ -88,14 +88,7 @@ def download_tmd(title_id: str, title_version: int = None, wiiu_endpoint: bool =
|
||||
if title_version is not None:
|
||||
tmd_url += "." + str(title_version)
|
||||
# Make the request.
|
||||
try:
|
||||
tmd_request = requests.get(url=tmd_url, headers={'User-Agent': 'wii libnup/1.0'}, stream=True)
|
||||
except requests.exceptions.ConnectionError:
|
||||
if endpoint_override:
|
||||
raise ValueError("A connection could not be made to the NUS endpoint. Please make sure that your endpoint "
|
||||
"override is valid.")
|
||||
else:
|
||||
raise Exception("A connection could not be made to the NUS endpoint. The NUS may be unavailable.")
|
||||
# Handle a 404 if the TID/version doesn't exist.
|
||||
if tmd_request.status_code != 200:
|
||||
raise ValueError("The requested Title ID or TMD version does not exist. Please check the Title ID and Title"
|
||||
@ -140,14 +133,7 @@ def download_ticket(title_id: str, wiiu_endpoint: bool = False, endpoint_overrid
|
||||
endpoint_url = _nus_endpoint[0]
|
||||
ticket_url = endpoint_url + title_id + "/cetk"
|
||||
# Make the request.
|
||||
try:
|
||||
ticket_request = requests.get(url=ticket_url, headers={'User-Agent': 'wii libnup/1.0'}, stream=True)
|
||||
except requests.exceptions.ConnectionError:
|
||||
if endpoint_override:
|
||||
raise ValueError("A connection could not be made to the NUS endpoint. Please make sure that your endpoint "
|
||||
"override is valid.")
|
||||
else:
|
||||
raise Exception("A connection could not be made to the NUS endpoint. The NUS may be unavailable.")
|
||||
if ticket_request.status_code != 200:
|
||||
raise ValueError("The requested Title ID does not exist, or refers to a non-free title. Tickets can only"
|
||||
" be downloaded for titles that are free on the NUS.")
|
||||
@ -187,15 +173,8 @@ def download_cert_chain(wiiu_endpoint: bool = False, endpoint_override: str = No
|
||||
endpoint_url = _nus_endpoint[0]
|
||||
tmd_url = endpoint_url + "0000000100000002/tmd.513"
|
||||
cetk_url = endpoint_url + "0000000100000002/cetk"
|
||||
try:
|
||||
tmd = requests.get(url=tmd_url, headers={'User-Agent': 'wii libnup/1.0'}, stream=True).content
|
||||
cetk = requests.get(url=cetk_url, headers={'User-Agent': 'wii libnup/1.0'}, stream=True).content
|
||||
except requests.exceptions.ConnectionError:
|
||||
if endpoint_override:
|
||||
raise ValueError("A connection could not be made to the NUS endpoint. Please make sure that your endpoint "
|
||||
"override is valid.")
|
||||
else:
|
||||
raise Exception("A connection could not be made to the NUS endpoint. The NUS may be unavailable.")
|
||||
# Assemble the certificate chain.
|
||||
cert_chain = b''
|
||||
# Certificate Authority data.
|
||||
@ -205,9 +184,8 @@ def download_cert_chain(wiiu_endpoint: bool = False, endpoint_override: str = No
|
||||
# XS (Ticket certificate) data.
|
||||
cert_chain += cetk[0x2A4:0x2A4 + 768]
|
||||
# Since the cert chain is always the same, check the hash to make sure nothing went wildly wrong.
|
||||
# This is currently disabled because of the possibility that one may be downloading non-retail certs (gasp!).
|
||||
#if hashlib.sha1(cert_chain).hexdigest() != "ace0f15d2a851c383fe4657afc3840d6ffe30ad0":
|
||||
# raise Exception("An unknown error has occurred downloading and creating the certificate.")
|
||||
if hashlib.sha1(cert_chain).hexdigest() != "ace0f15d2a851c383fe4657afc3840d6ffe30ad0":
|
||||
raise Exception("An unknown error has occurred downloading and creating the certificate.")
|
||||
return cert_chain
|
||||
|
||||
|
||||
@ -246,14 +224,7 @@ def download_content(title_id: str, content_id: int, wiiu_endpoint: bool = False
|
||||
endpoint_url = _nus_endpoint[0]
|
||||
content_url = endpoint_url + title_id + "/000000" + content_id_hex
|
||||
# Make the request.
|
||||
try:
|
||||
content_request = requests.get(url=content_url, headers={'User-Agent': 'wii libnup/1.0'}, stream=True)
|
||||
except requests.exceptions.ConnectionError:
|
||||
if endpoint_override:
|
||||
raise ValueError("A connection could not be made to the NUS endpoint. Please make sure that your endpoint "
|
||||
"override is valid.")
|
||||
else:
|
||||
raise Exception("A connection could not be made to the NUS endpoint. The NUS may be unavailable.")
|
||||
if content_request.status_code != 200:
|
||||
raise ValueError("The requested Title ID does not exist, or an invalid Content ID is present in the"
|
||||
" content records provided.\n Failed while downloading Content ID: 000000" +
|
||||
|
@ -160,8 +160,7 @@ class Ticket:
|
||||
limit_value = int.from_bytes(ticket_data.read(4))
|
||||
self.title_limits_list.append(_TitleLimit(limit_type, limit_value))
|
||||
# Check certs to see if this is a retail or dev ticket. Treats unknown certs as being retail for now.
|
||||
if (self.signature_issuer.find("Root-CA00000002-XS00000006") != -1 or
|
||||
self.signature_issuer.find("Root-CA00000002-XS00000004") != -1):
|
||||
if self.signature_issuer.find("Root-CA00000002-XS00000006") != -1:
|
||||
self.is_dev = True
|
||||
else:
|
||||
self.is_dev = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user