Created
November 22, 2020 13:48
-
-
Save Xzonn/4384a095271c07e907dd4a676654e970 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import struct | |
walk = os.walk("./") | |
data = {} | |
for root, dirs, files in walk: | |
for fileName in files: | |
fullName = os.path.join(root, fileName) | |
if fullName.endswith(".uexp"): | |
with open(fullName, "rb") as f: | |
raw = f.read() | |
texts = [] | |
pos = raw.find(b'\xff\xff\xff') | |
while pos > -1: | |
name = '' | |
newPos = pos - 3 | |
while raw[newPos] != 0: | |
name = chr(raw[newPos]) + name | |
newPos -= 1 | |
# if name != '': | |
if True: | |
content = '' | |
pos += 3 | |
while raw[pos:pos + 2] != b'\0\0': | |
content += chr(raw[pos] + (raw[pos + 1] << 8)) | |
pos += 2 | |
texts.append([name, content]) | |
pos = raw.find(b'\xff\xff\xff', pos + 1) | |
data[fullName] = texts | |
with open("export.txt", "w", -1, "utf-8") as f: | |
for i in data: | |
if len(data[i]) > 1: | |
f.write(i.replace("\\", "/") + "\n") | |
f.write("\n".join(["\t".join([j.replace("\n", "\\n").replace("\r", "\\r").replace("\t", "\\t") for j in i]) for i in data[i][1:]])) | |
f.write("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment