User:Sanhard/SubtitleDumper

Python 3 file. Run like, python subtitledumper.py import io import sys

def readDataOffset(dat): dat.seek(0x14, 0) # Go to 0x14 in the file i = int.from_bytes(dat.read(4), byteorder="little") # Get starting position of data. i = i + 0x6DC0 #Offset further by length of garbage data return i

def main: with open(sys.argv[1], 'rb') as datastream: dat = io.BytesIO(datastream.read) offset = readDataOffset(dat) size = dat.getbuffer.nbytes print(offset) #Start writing lines dat.seek(offset, 0)

spacecount = 0 output = "" while dat.tell != size: char = dat.read(1) if char != b'\x00': output += char.decode('utf-8').rstrip('\r') spacecount = 0 elif char == b'\x00': spacecount += 1 if spacecount == 3: output += " \n" f = open(sys.argv[1] + ".txt", "w") f.write(output) f.close

main print("Operation Complete")