Fix getting a title's type

This commit is contained in:
Campbell 2024-09-05 11:07:14 -04:00
parent 0edd4fa6bb
commit 7c2f0fb21f
Signed by: NinjaCheetah
GPG Key ID: 670C282B3291D63D

View File

@ -45,7 +45,7 @@ class TMD:
self.ios_tid: str = "" # The Title ID of the IOS version the associated title runs on. self.ios_tid: str = "" # The Title ID of the IOS version the associated title runs on.
self.ios_version: int = 0 # The IOS version the associated title runs on. self.ios_version: int = 0 # The IOS version the associated title runs on.
self.title_id: str = "" # The Title ID of the associated title. self.title_id: str = "" # The Title ID of the associated title.
self.title_type: str = "" # The type of the associated title. self.title_type: bytes = b'' # The type of the associated title. Should always be 00000001 in a Wii TMD.
self.group_id: int = 0 # The ID of the publisher of the associated title. self.group_id: int = 0 # The ID of the publisher of the associated title.
self.region: int = 0 # The ID of the region of the associated title. self.region: int = 0 # The ID of the region of the associated title.
self.ratings: bytes = b'' # The parental controls rating of the associated title. self.ratings: bytes = b'' # The parental controls rating of the associated title.
@ -107,11 +107,10 @@ class TMD:
title_id_bin = tmd_data.read(8) title_id_bin = tmd_data.read(8)
title_id_hex = binascii.hexlify(title_id_bin) title_id_hex = binascii.hexlify(title_id_bin)
self.title_id = str(title_id_hex.decode()) self.title_id = str(title_id_hex.decode())
# Type of content. # Type of the title. This is an internal property used to show if this title is for the ill-fated
# NetCard (0), or the Wii (1), and is therefore always 1 for Wii TMDs.
tmd_data.seek(0x194) tmd_data.seek(0x194)
content_type_bin = tmd_data.read(4) self.title_type = tmd_data.read(4)
content_type_hex = binascii.hexlify(content_type_bin)
self.title_type = str(content_type_hex.decode())
# Publisher of the title. # Publisher of the title.
tmd_data.seek(0x198) tmd_data.seek(0x198)
self.group_id = int.from_bytes(tmd_data.read(2)) self.group_id = int.from_bytes(tmd_data.read(2))
@ -188,8 +187,8 @@ class TMD:
tmd_data += binascii.unhexlify(self.ios_tid) tmd_data += binascii.unhexlify(self.ios_tid)
# Title's Title ID. # Title's Title ID.
tmd_data += binascii.unhexlify(self.title_id) tmd_data += binascii.unhexlify(self.title_id)
# Content type. # Title type.
tmd_data += binascii.unhexlify(self.title_type) tmd_data += self.title_type
# Group ID. # Group ID.
tmd_data += int.to_bytes(self.group_id, 2) tmd_data += int.to_bytes(self.group_id, 2)
# 2 bytes of zero for reasons. # 2 bytes of zero for reasons.
@ -305,7 +304,7 @@ class TMD:
def get_title_type(self) -> str: def get_title_type(self) -> str:
""" """
Gets the type of the TMD's associated title. Gets the type of the title this TMD describes. The title_type field is not related to these types.
Can be one of several possible values: Can be one of several possible values:
'System', 'Game', 'Channel', 'SystemChannel', 'GameChannel', or 'HiddenChannel' 'System', 'Game', 'Channel', 'SystemChannel', 'GameChannel', or 'HiddenChannel'
@ -315,7 +314,7 @@ class TMD:
str str
The type of the title. The type of the title.
""" """
match self.title_type: match self.title_id[:8]:
case '00000001': case '00000001':
return "System" return "System"
case '00010000': case '00010000':