Wrote a program because the subtitles I got for GochiUsa are from a TVRIP but the raws are from Blu-ray so they didn’t line up

dumb python code

the file input is passed in as an argument and everything else will be prompted, creates filename_treated.ass in the same directory as the input file because why not

import re
import datetime
import sys

filename = sys.argv[1]

intvStartString = input('enter starting timecode(H:M:S.mS): ')
intvStartTime = datetime.datetime.strptime(intvStartString, "%H:%M:%S.%f")
intvEndString = input('enter ending timecode(H:M:S.mS): ')
intvEndTime = datetime.datetime.strptime(intvEndString, "%H:%M:%S.%f")
changeInTime = input('enter your timecode offset(S.mS): ')

matchingTime = "00:00.00"
filedata = open(filename, 'r', encoding="utf-8").read()
with open(filename, 'r', encoding="utf-8") as file:
        for line in file:
                for i in re.finditer('[0-9]{1}:[0-9]{2}:[0-9]{2}.[0-9]{2}', line):
                        matchingTime ='[0-9]{1}:[0-9]{2}:[0-9]{2}.[0-9]{2}', line)
                        if matchingTime == None:
                        interpretedMatchingTime = datetime.datetime.strptime(, "%H:%M:%S.%f")
                        if interpretedMatchingTime < intvStartTime or interpretedMatchingTime > intvEndTime:
                        interpretedAdjustedMatchingTime = datetime.datetime.strptime(, "%H:%M:%S.%f") + datetime.timedelta( seconds=int( changeInTime[:changeInTime.find('.')] ) , microseconds=int( changeInTime[changeInTime.find('.')+1:] ))
                        convertedInterpretedMatchingTime = interpretedAdjustedMatchingTime.strftime("%H:%M:%S.%f")
                        treatedConvertedInterpretedMatchingTime = convertedInterpretedMatchingTime[1:-4]
                        filedata = filedata.replace(,treatedConvertedInterpretedMatchingTime)
                        line = line.replace(,"")

destFilename = filename[:-4] + "_treated.ass"
with open(destFilename, 'x', encoding="utf-8") as file:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s