metricsubs-segmenter / ass_extract.py
metricv's picture
Update
efaf91a verified
raw
history blame
396 Bytes
import ass
import os
import sys
SUB_NAME = sys.argv[1]
en_name = "Extracted - " + os.path.splitext(SUB_NAME)[0] + ".txt"
with open(SUB_NAME, "r", encoding='utf-8-sig') as f:
doc = ass.parse(f)
en_file = open(en_name, "w")
for e in doc.events:
if isinstance(e, ass.line.Dialogue) and e.style == '英':
en_file.write(e.text.strip())
en_file.write("\n")
en_file.close()