mirror of
https://github.com/NinjaCheetah/WiiPy.git
synced 2025-04-26 13:21:01 -04:00
Allowed symbols in TIDs for wad edit/tmd edit
This commit is contained in:
parent
fa4e9bf2f1
commit
f3eb127aee
@ -16,7 +16,8 @@ def _print_tmd_info(tmd: libWiiPy.title.TMD):
|
||||
ascii_tid = (bytes.fromhex(tmd.title_id[8:].replace("00", "30"))).decode("ascii")
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if ascii_tid.isalnum():
|
||||
pattern = r"^[a-z0-9!@#$%^&*]{4}$"
|
||||
if re.fullmatch(pattern, ascii_tid, re.IGNORECASE):
|
||||
print(f" Title ID: {tmd.title_id.upper()} ({ascii_tid})")
|
||||
else:
|
||||
print(f" Title ID: {tmd.title_id.upper()}")
|
||||
@ -87,10 +88,11 @@ def _print_ticket_info(ticket: libWiiPy.title.Ticket):
|
||||
print(f"Ticket Info")
|
||||
ascii_tid = ""
|
||||
try:
|
||||
ascii_tid = str(bytes.fromhex(ticket.title_id.decode()[8:].replace("00", "30")).decode("ascii")).upper()
|
||||
ascii_tid = str(bytes.fromhex(ticket.title_id.decode()[8:].replace("00", "30")).decode("ascii"))
|
||||
except UnicodeDecodeError or binascii.Error:
|
||||
pass
|
||||
if ascii_tid.isalnum():
|
||||
pattern = r"^[a-z0-9!@#$%^&*]{4}$"
|
||||
if re.fullmatch(pattern, ascii_tid, re.IGNORECASE):
|
||||
print(f" Title ID: {ticket.title_id.decode().upper()} ({ascii_tid})")
|
||||
else:
|
||||
print(f" Title ID: {ticket.title_id.decode().upper()}")
|
||||
@ -128,12 +130,11 @@ def _print_ticket_info(ticket: libWiiPy.title.Ticket):
|
||||
|
||||
def _print_wad_info(title: libWiiPy.title.Title):
|
||||
print(f"WAD Info")
|
||||
channel_title = ""
|
||||
try:
|
||||
channel_title = title.get_channel_name()
|
||||
except ValueError:
|
||||
pass
|
||||
if channel_title:
|
||||
banner_data = title.get_content_by_index(0)
|
||||
banner_u8 = libWiiPy.archive.U8Archive()
|
||||
banner_u8.load(banner_data)
|
||||
if banner_u8.imet_header.magic != "":
|
||||
channel_title = banner_u8.imet_header.get_channel_names(banner_u8.imet_header.LocalizedTitles.TITLE_ENGLISH)
|
||||
print(f" Channel Name: {channel_title}")
|
||||
match title.wad.wad_type:
|
||||
case "Is":
|
||||
|
@ -159,7 +159,6 @@ def handle_wad_edit(args):
|
||||
title.tmd.ios_tid = new_ios_tid
|
||||
edits_made = True
|
||||
if args.type is not None:
|
||||
print(title.tmd.title_id)
|
||||
new_tid = title_edit_type(title.tmd.title_id, args.type)
|
||||
title.set_title_id(new_tid)
|
||||
edits_made = True
|
||||
|
@ -2,6 +2,7 @@
|
||||
# https://github.com/NinjaCheetah/WiiPy
|
||||
|
||||
import binascii
|
||||
import re
|
||||
from modules.core import fatal_error
|
||||
|
||||
|
||||
@ -18,11 +19,12 @@ def title_edit_ios(new_ios: str) -> str:
|
||||
|
||||
|
||||
def title_edit_tid(tid: str, new_tid: str) -> str:
|
||||
# Setting a new TID, only changing TID low since this expects a 4 character ASCII input.
|
||||
if len(new_tid) != 4:
|
||||
fatal_error(f"The specified Title ID is not valid! The new Title ID should be 4 characters long.")
|
||||
if not new_tid.isalnum():
|
||||
fatal_error(f"The specified Title ID is not valid! The new Title ID should be alphanumeric.")
|
||||
# Setting a new TID, only changing TID low since this expects a 4 character input with letters, numbers, and some
|
||||
# symbols.
|
||||
pattern = r"^[a-z0-9!@#$%^&*]{4}$"
|
||||
if not re.fullmatch(pattern, new_tid, re.IGNORECASE):
|
||||
fatal_error(f"The specified Title ID is not valid! The new Title ID should be 4 characters and only include "
|
||||
f"letters, numbers, and the special characters \"!@#$%&*\".")
|
||||
# Get the current TID high, because we want to preserve the title type while only changing the TID low.
|
||||
tid_high = tid[:8]
|
||||
new_tid = f"{tid_high}{str(binascii.hexlify(new_tid.encode()), 'ascii')}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user