From 99e78cd9a4014a79699362f120bbbf39e06231f2 Mon Sep 17 00:00:00 2001 From: Stewie Date: Sat, 13 Aug 2022 00:13:24 -0400 Subject: [PATCH] Create new function to extract all skits --- ToolsTOR.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ToolsTOR.py b/ToolsTOR.py index e79ec3c..0c30721 100644 --- a/ToolsTOR.py +++ b/ToolsTOR.py @@ -14,6 +14,7 @@ from xml.dom import minidom from pathlib import Path import string import io +import pak2 class ToolsTOR(ToolsTales): @@ -73,6 +74,25 @@ class ToolsTOR(ToolsTales): self.extract_TheirSce_XML(scpk_file) self.id = 1 + + # Extract all the skits files + def extract_Skits(self): + i = 1 + os.makedirs( self.skit_XML_patch + "XML", exist_ok=True) + list_pak2_files = [ self.dat_archive_extract + "PAK2/" + ele for ele in os.listdir(self.dat_archive_extract + "PAK2")] + for file_path in list_pak2_files: + + if os.path.isfile(file_path) and file_path.endswith(".pak2"): + with open(file_path, "rb") as pak: + data = pak.read() + theirsce = io.BytesIO(pak2.get_theirsce_from_pak2(data)) + self.extract_TheirSce_XML(theirsce, re.sub("\.\d+", "", file_path), self.skit_XML_patch, "Skits") + + print("Writing file %05d" % i, end="\r") + i += 1 + + print("Writing file %05d..." % (i-1)) + return def get_theirsce_from_scpk(self, scpk_file_name, debug=False)->bytes: