Update WAD extraction code to name .apps correctly and work with current libWiiPy main

This commit is contained in:
Campbell 2024-03-05 22:18:15 -05:00
parent a6f660f627
commit 0f7c40a88f
Signed by: NinjaCheetah
GPG Key ID: B547958AF96ED344

View File

@ -3,7 +3,7 @@
import os
import pathlib
import struct
import binascii
from libWiiPy import wad, tmd, ticket, content
@ -23,24 +23,29 @@ def extract_wad_to_folder(in_file_input: str, out_folder_input: str):
title_key = ticket_data.get_title_key()
cert_name = tmd_data.get_title_id() + ".cert"
cert_name = tmd_data.title_id + ".cert"
cert_out = open(os.path.join(out_folder, cert_name), "wb")
cert_out.write(wad_data.get_cert_data())
cert_out.close()
tmd_name = tmd_data.get_title_id() + ".tmd"
tmd_name = tmd_data.title_id + ".tmd"
tmd_out = open(os.path.join(out_folder, tmd_name), "wb")
tmd_out.write(wad_data.get_tmd_data())
tmd_out.close()
ticket_name = tmd_data.get_title_id() + ".tik"
ticket_name = tmd_data.title_id + ".tik"
ticket_out = open(os.path.join(out_folder, ticket_name), "wb")
ticket_out.write(wad_data.get_ticket_data())
ticket_out.close()
for content_file in range(0, tmd_data.get_num_contents()):
meta_name = tmd_data.title_id + ".footer"
meta_out = open(os.path.join(out_folder, meta_name), "wb")
meta_out.write(wad_data.get_meta_data())
meta_out.close()
for content_file in range(0, tmd_data.num_contents):
content_file_name = "000000"
content_file_name += str(hex(content_file)) + ".app"
content_file_name += str(binascii.hexlify(content_file.to_bytes()).decode()) + ".app"
content_out = open(os.path.join(out_folder, content_file_name), "wb")
content_out.write(content_data.get_content(content_file, title_key))
content_out.close()