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