diff --git a/VTT Formatter.py b/VTT Formatter.py index f9af72f..ea2709a 100644 --- a/VTT Formatter.py +++ b/VTT Formatter.py @@ -14,7 +14,7 @@ # $ VTT Formatter.py [DIR] # $ VTT Formatter.py ./subs -print "Searching inside : "+sys.argv[1] +print(f"Searching inside : {sys.argv[1]}") newdirectory = sys.argv[1]+"txt" if not os.path.exists(newdirectory): @@ -25,16 +25,19 @@ newfile = open(os.path.join(newdirectory,file.replace(".vtt", ".txt")),'w') #Creates a newfile if file.endswith(".vtt"): - print "Formating : "+file #Shows current File + print("Formating : "+file) #Shows current File with open(os.path.join(sys.argv[1], file)) as f: + previous = '0' for line in f: #a line for each file - if not line.startswith('0') : #Couldnt Get the "or" working + if line.find('-->') == -1 : #Avoid timestanps if not line.startswith('WEBVTT') :#Cleaning if not line.startswith('Kind:') :#Cleaning if not line.startswith('Language:') :#Cleaning if not line.startswith('\n') :#Cleaning if not line.startswith('[BLANK_AUDIO]') :#Cleaning - newfile.write("%s" % line) #Add new line to new file - combined.write("%s" % line) #Add new line to combinedfile - print "DONE!" #NEXT ONE! + if not line.startswith(previous) :#Avoiding repetitions + newfile.write("%s" % line) #Add new line to new file + combined.write("%s" % line) #Add new line to combinedfile + previous = line + print("DONE!") #NEXT ONE!