mirror of
https://github.com/NinjaCheetah/WiiPy.git
synced 2025-04-27 13:51:02 -04:00
WADs patched with iospatch are also now fakesigned by default when exported.
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
# "modules/title/fakesign.py" from WiiPy by NinjaCheetah
|
|
# https://github.com/NinjaCheetah/WiiPy
|
|
|
|
import pathlib
|
|
import libWiiPy
|
|
|
|
|
|
def handle_fakesign(args):
|
|
input_path = pathlib.Path(args.input)
|
|
if args.output is not None:
|
|
output_path = pathlib.Path(args.output)
|
|
else:
|
|
output_path = pathlib.Path(args.input)
|
|
|
|
if not input_path.exists():
|
|
raise FileNotFoundError(input_path)
|
|
|
|
if input_path.suffix.lower() == ".tmd":
|
|
tmd = libWiiPy.title.TMD()
|
|
tmd.load(open(input_path, "rb").read())
|
|
tmd.fakesign()
|
|
open(output_path, "wb").write(tmd.dump())
|
|
print("TMD fakesigned successfully!")
|
|
elif input_path.suffix.lower() == ".tik":
|
|
tik = libWiiPy.title.Ticket()
|
|
tik.load(open(input_path, "rb").read())
|
|
tik.fakesign()
|
|
open(output_path, "wb").write(tik.dump())
|
|
print("Ticket fakesigned successfully!")
|
|
elif input_path.suffix.lower() == ".wad":
|
|
title = libWiiPy.title.Title()
|
|
title.load_wad(open(input_path, "rb").read())
|
|
title.fakesign()
|
|
open(output_path, "wb").write(title.dump_wad())
|
|
print("WAD fakesigned successfully!")
|
|
else:
|
|
raise TypeError("This does not appear to be a TMD, Ticket, or WAD! Cannot fakesign.")
|