libWiiPy.title.tmd Module#

The libWiiPy.title.tmd module provides support for handling TMD (Title Metadata) files, which contain the metadata of both digital and physical Wii titles. This module allows for easy parsing and editing of TMDs.

Module Contents#

class libWiiPy.title.tmd.TMD#

Bases: object

A TMD object that allows for either loading and editing an existing TMD or creating one manually if desired.

title_id#

The title ID of the title listed in the TMD.

Type:

str

title_version#

The version of the title listed in the TMD.

Type:

int

tmd_version#

The version of the TMD.

Type:

int

ios_tid#

The title ID of the IOS the title runs on.

Type:

str

ios_version#

The IOS version the title runs on.

Type:

int

num_contents#

The number of contents listed in the TMD.

Type:

int

class AccessFlags(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: IntEnum

AHB = 0#
DVD_VIDEO = 1#
dump() bytes#

Dumps the TMD object back into bytes.

Returns:

The full TMD file as bytes.

Return type:

bytes

fakesign() None#

Fakesigns this TMD for the trucha bug.

This is done by brute-forcing a TMD body hash starting with 00, causing it to pass signature verification on older IOS versions that incorrectly check the hash using strcmp() instead of memcmp(). The signature will also be erased and replaced with all NULL bytes.

The hash is brute-forced by incrementing an unused 16-bit integer in the TMD by 1 until an appropriate hash is found.

This modifies the TMD object in place. You will need to call this method after any changes, and before dumping the TMD object back into bytes.

get_access_right(flag: int) bool#

Gets whether the specified access rights flag is enabled or not. This is done by checking the specified bit. Possible flags and their corresponding bits are defined in AccessFlags.

Parameters:

flag (int) – The flag to check.

Returns:

True if the flag is enabled, False otherwise.

Return type:

bool

get_content_record(record) _ContentRecord#

Gets the content record at the specified index.

Parameters:

record (int) – The content record to be retrieved.

Returns:

A ContentRecord object containing the data in the content record.

Return type:

_ContentRecord

get_content_size(absolute=False, dlc=False) int#

Gets the installed size of the content listed in the TMD, in bytes. This does not include the size of hash tree content, so the size of disc titles will not be calculated. The “absolute” option determines whether shared content sizes should be included in the total size or not. This option defaults to False. The “dlc” option determines whether DLC content sizes should be included in the total size or not. This option also defaults to False.

Parameters:
  • absolute (bool, optional) – Whether shared contents should be included in the total size or not. Defaults to False.

  • dlc (bool, optional) – Whether DLC contents should be included in the total size or not. Defaults to False.

Returns:

The installed size of the content, in bytes.

Return type:

int

get_content_size_blocks(absolute=False, dlc=False) int#

Gets the installed size of the content listed in the TMD, in the Wii’s displayed “blocks” format. The “absolute” option determines whether shared content sizes should be included in the total size or not. This option defaults to False. The “dlc” option determines whether DLC content sizes should be included in the total size or not. This option also defaults to False.

1 Wii block is equal to 128KiB, and if any amount of a block is used, the entire block is considered used.

Parameters:
  • absolute (bool, optional) – Whether shared contents should be included in the total size or not. Defaults to False.

  • dlc (bool, optional) – Whether DLC contents should be included in the total size or not. Defaults to False.

Returns:

The installed size of the content, in blocks.

Return type:

int

get_content_type(content_index: int) str#

Gets the type of content contained in the TMD’s associated title.

Can be one of several possible values: ‘Normal’, ‘Development/Unknown’, ‘Hash Tree’, ‘DLC’, or ‘Shared’

Parameters:

content_index (int) – The index of the content you want the type of.

Returns:

The type of content.

Return type:

str

get_is_fakesigned() bool#

Checks the TMD object to see if it is currently fakesigned. For a description of fakesigning, refer to the fakesign() method.

Returns:

True if the TMD is fakesigned, False otherwise.

Return type:

bool

get_title_region() str#

Gets the system region specified in the TMD. This is not necessarily the true region of the title, but is the hardware region that this title is designed and allowed to be run on.

Can be one of several possible values: ‘JPN’, ‘USA’, ‘EUR’, ‘None’, or ‘KOR’.

Returns:

The region of the title.

Return type:

str

get_title_type() str#

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: ‘System’, ‘Game’, ‘Channel’, ‘SystemChannel’, ‘GameChannel’, or ‘HiddenChannel’

Returns:

The type of the title.

Return type:

str

load(tmd: bytes) None#

Loads raw TMD data and sets all attributes of the TMD object. This allows for manipulating an already existing TMD.

Parameters:

tmd (bytes) – The data for the TMD you wish to load.

set_title_id(title_id) None#

Sets the Title ID property of the TMD. Recommended over setting the property directly because of input validation.

Parameters:

title_id (str) – The new Title ID of the title.

set_title_version(new_version: str | int) None#

Sets the version of the title in the TMD. Recommended over setting the data directly because of input validation.

Accepts either standard form (vX.X) as a string or decimal form (vXXX) as an integer.

Parameters:

new_version (str, int) – The new version of the title. See description for valid formats.