import ass | |
import os | |
import sys | |
SUB_NAME = sys.argv[1] | |
sub_basename = os.path.basename(SUB_NAME) | |
en_name = "Extracted - " + os.path.splitext(sub_basename)[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() |