-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnityCN.py
More file actions
52 lines (41 loc) · 1.49 KB
/
UnityCN.py
File metadata and controls
52 lines (41 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import argparse
import UnityPy
from tqdm import tqdm
from concurrent.futures import ThreadPoolExecutor, as_completed
def process(ip, op):
os.makedirs(os.path.dirname(op), exist_ok=True)
with open(op, "wb") as f:
f.write((UnityPy.load(ip)).file.save())
return True, None
def main():
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("-i", required=True, help="输入文件夹")
parser.add_argument("-o", required=True, help="输出文件夹")
parser.add_argument("-k", required=True, help="32位十六进制字符串格式的解密密钥")
a = parser.parse_args()
key_bytes = bytes.fromhex(a.k)
UnityPy.set_assetbundle_decrypt_key(key_bytes)
task = []
for r, _, files in os.walk(a.i):
for n in files:
ip = os.path.join(r, n)
rp = os.path.relpath(r, a.i)
task.append((ip, os.path.join(a.o, rp, n)))
sc = 0
fc = 0
with ThreadPoolExecutor(max_workers=32) as e:
fp = {e.submit(process, ip, op): ip for ip, op in task}
pb = tqdm(as_completed(fp), total=len(task), desc="处理中", unit="个文件")
for fu in pb:
ip = fp[fu]
s, em = fu.result()
if s:
sc += 1
else:
fc += 1
pb.set_postfix_str(f"失败: {os.path.basename(ip)}")
print(f"成功: {sc} 个")
print(f"失败: {fc} 个")
if __name__ == "__main__":
main()