1
0
mirror of https://github.com/Escartem/AnimeWwise.git synced 2026-06-08 01:14:31 +08:00

can extract files again

This commit is contained in:
Escartem
2024-07-23 15:26:53 +02:00
parent d96771c60d
commit 9498fabeac
3 changed files with 99 additions and 46 deletions

View File

@@ -29,8 +29,6 @@ skips = "000000000" # used for debugging
class WwiseExtract:
def __init__(self):
# self.map = _map
# self.format = _format
self.paths = {
"input": "",
@@ -41,8 +39,6 @@ class WwiseExtract:
self.allocator = Allocator()
# self.progress = progress
def path(self, base, path):
base_path = self.paths[base]
if base == "temp":
@@ -307,7 +303,6 @@ class WwiseExtract:
print("-"*30)
print("Done extracting everything !")
### loading files ###
def load_folder(self, _map, path):
@@ -318,6 +313,9 @@ class WwiseExtract:
files = [f for f in os.listdir(path) if f.endswith(".pck")]
if len(files) == 0:
return None
for file in files:
self.load_file(os.path.join(path, file))
@@ -370,11 +368,28 @@ class WwiseExtract:
### extracting files ###
def extract_files(self, _input):
# load all pck, then extract each file and apply conversion if required
# allocator.load_file(os.path.join(_input, "2050.pck"))
# allocator.read_at("2050.pck", 0, 0)
pass
def extract_files(self, _input, files, output, format, progress):
all_sources = list(set([e["source"] for e in files]))
for source in all_sources:
self.allocator.load_file(os.path.join(_input, source))
pos = 0
for file in files:
pos += 1
progress(["total", pos * 100 // len(files)])
data = self.allocator.read_at(file["source"], file["offset"], file["size"])
filepath = os.path.join("/".join(file["path"]), file["name"])
fullpath = os.path.join(output, filepath)
os.makedirs(os.path.dirname(fullpath), exist_ok=True)
with open(fullpath, "wb") as f:
f.write(data)
f.close()
self.allocator.free_mem()
os.startfile(output)
### other ###
def reset(self):