-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathptsearch.py
30 lines (26 loc) · 913 Bytes
/
ptsearch.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
#v 1.0.1
import hashlib
def main():
off = 0
with (open('DJMax.DMP', 'rb')) as file_:
file_ = file_.read()
off=file_.find(b"PTFF", off+4)
while off != -1:
if file_[off+4:off+4+8] == (b"\x00"*8):
off=file_.find(b"PTFF", off+4)
continue
num_tracks = int.from_bytes(file_[off+0x0c:off+0x0c+0x2], "little")
endoff = off+4
for _ in range(num_tracks):
endoff=file_.find(b"EZTR", endoff+1 )
if endoff == -1:
break
if endoff == -1:
break
endoff+=0x4e
fileout = file_[off:endoff]
with open(f"{hashlib.md5(fileout).hexdigest()[:16]}.pt", "wb") as f:
f.write(fileout)
off=file_.find(b"PTFF", off+4)
if __name__ == '__main__':
main()