-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
75 lines (60 loc) · 2.45 KB
/
main.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import keyGrabber, os, sys, pathlib, env
from extractor import extract
def extractMany(dir_:str = "./", **kwargs):
files = os.listdir( dir_ )
if "inputFiles" in files:
files += os.listdir( dir_ + "inputFiles/")
extracted = 0
for file_ in (f for f in files if len(f) > 4 and f[-4:] == ".pak") :
print(f"Extracting {file_.split('/')[-1]}")
try:
extract(dir_+file_ , **kwargs)
except Exception as e:
print(e)
extracted += 1
if extracted == 0:
print("No .pak files found.")
def autoExtractAll():
keyGrabber.main()
extractMany( )
if __name__ == "__main__":
kwargs_ = {}
if len(sys.argv) > 1:
if "-nofolders" in sys.argv:
kwargs_["noIndividualFoldersParam"] = True
if "-getkeys" in sys.argv:
keyGrabber.main( )
if "-extractall" in sys.argv:
extractMany( **kwargs_ )
if ".pak" in "".join(sys.argv):
for file_ in [a for a in sys.argv if len(a) >= 4 and a[-4:] == ".pak"]:
print(f"Extracting {pathlib.Path(file_).name}")
try:
extract( file_ , **kwargs_)
except Exception as e:
print(e)
else:
extractMany( **kwargs_ )
else:
if ( env.RELEASE_BUILD ) :
print(f'''No file specified.
Usages:
Easy mode: Automatically extract all paks in the folder (place a game .exe in the root folder also) : {env.COMMAND_NAME}
Extract a file: {env.COMMAND_NAME} file1.pak
Extract all paks in the folder : {env.COMMAND_NAME} -extractall
parameter "-nofolders" : do not make individual pak folders.
Requirement: The keys, or an .exe file with them , must be placed in this folder.
Some known files containing the keys are: TR1.exe , O2Mania*.exe , djmax*.exe , Pak Extract.exe , yomax.exe
For trilogy (not implemented yet), you must also be able to get USB_16128_10.dat or get it with a tool that reads the usb stick .
Executing easy mode...
''')
autoExtractAll()
else:
...
'''def main_profile(fileName : str = "./System.pak"):
import cProfile
logging.basicConfig(level=logging.ERROR)
cProfile.run(f"openXip('{fileName}')", "profile_output.prof", sort="cumulative" )
stats = pstats.Stats("profile_output.prof")
stats.sort_stats('cumulative')
stats.print_stats(30)'''