mirror of
https://github.com/NinjaCheetah/libWiiPy.git
synced 2025-04-28 22:21:00 -04:00
Get WAD content records.
This commit is contained in:
parent
ed21fc0704
commit
c5025348dd
8
.gitignore
vendored
8
.gitignore
vendored
@ -163,4 +163,10 @@ cython_debug/
|
|||||||
|
|
||||||
# Allows me to keep TMD files in my repository folder for testing without accidentally publishing them
|
# Allows me to keep TMD files in my repository folder for testing without accidentally publishing them
|
||||||
*.tmd
|
*.tmd
|
||||||
*.wad
|
*.wad
|
||||||
|
out_prod/
|
||||||
|
remakewad.pl
|
||||||
|
|
||||||
|
# Also awful macOS files
|
||||||
|
*._*
|
||||||
|
*.DS_Store
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
import io
|
import io
|
||||||
import binascii
|
import binascii
|
||||||
|
import struct
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
@ -41,7 +42,8 @@ class TMD:
|
|||||||
self.title_version: int
|
self.title_version: int
|
||||||
self.num_contents: int
|
self.num_contents: int
|
||||||
self.boot_index: int
|
self.boot_index: int
|
||||||
self.content_record: List[ContentRecord]
|
self.content_record: List[ContentRecord] = []
|
||||||
|
self.content_record_hdr: List = []
|
||||||
# Load data from TMD file
|
# Load data from TMD file
|
||||||
with io.BytesIO(tmd) as tmddata:
|
with io.BytesIO(tmd) as tmddata:
|
||||||
# Signing certificate issuer
|
# Signing certificate issuer
|
||||||
@ -101,6 +103,13 @@ class TMD:
|
|||||||
# Content index in content list that contains the boot file
|
# Content index in content list that contains the boot file
|
||||||
tmddata.seek(0x1E0)
|
tmddata.seek(0x1E0)
|
||||||
self.boot_index = tmddata.read(2)
|
self.boot_index = tmddata.read(2)
|
||||||
|
# Got content records for the number of contents in num_contents.
|
||||||
|
i = 0
|
||||||
|
while i < self.num_contents:
|
||||||
|
tmddata.seek(0x1E4 + (36 * i))
|
||||||
|
self.content_record_hdr = struct.unpack(">LHH4x4s20s", tmddata.read(36))
|
||||||
|
self.content_record.append(ContentRecord(self.content_record_hdr[0], self.content_record_hdr[1], self.content_record_hdr[2], self.content_record_hdr[3], self.content_record_hdr[4]))
|
||||||
|
i += 1
|
||||||
|
|
||||||
def get_title_id(self):
|
def get_title_id(self):
|
||||||
"""Returns the TID of the TMD's associated title."""
|
"""Returns the TID of the TMD's associated title."""
|
||||||
@ -183,3 +192,7 @@ class TMD:
|
|||||||
def get_num_contents(self):
|
def get_num_contents(self):
|
||||||
"""Returns the number of contents listed in the TMD."""
|
"""Returns the number of contents listed in the TMD."""
|
||||||
return self.num_contents
|
return self.num_contents
|
||||||
|
|
||||||
|
def get_content_records(self, record):
|
||||||
|
"""Returns all values for the specified content record."""
|
||||||
|
return self.content_record[record].cid, self.content_record[record].index, self.content_record[record].content_type, self.content_record[record].content_size, self.content_record[record].content_hash
|
||||||
|
Loading…
x
Reference in New Issue
Block a user