Convert all files in the same folder

This commit is contained in:
Jason Lobo 2020-11-01 16:32:20 +00:00
parent 49d0f505b1
commit 80e98d9d36

View file

@ -1,11 +1,8 @@
import pathlib
import pysubs2
from datetime import datetime
from pathlib import Path
pathlib.Path(Path(__file__).parent / 'cnt').mkdir(parents=True, exist_ok=True)
# Files auto-generated by YT have each subtitle line repeating 3 times, once at
# the end of a pair, once by itself and once at the beginning of a pair.
# But sometimes only the first case (end of a pair) exists, which are lines
@ -54,10 +51,10 @@ for srt_file in [x for x in Path(__file__).parent.glob('**/*.srt') if x.is_file(
# Make .en.cnt with lines then times
with open(str(Path(__file__).parent / 'cnt') + '\\' + srt_file.name[:-7] + '.en.cnt', 'a') as cnt_file:
with open(str(Path(__file__).parent) + '\\' + srt_file.name[:-7] + '.en.cnt', 'a') as cnt_file:
for i in lines:
cnt_file.write(i)
with open(str(Path(__file__).parent / 'cnt') + '\\' + srt_file.name[:-7] + '.en.cnt', 'a') as cnt_file:
with open(str(Path(__file__).parent) + '\\' + srt_file.name[:-7] + '.en.cnt', 'a') as cnt_file:
for i in times:
cnt_file.write(str(i))