File size: 443 Bytes
efaf91a
 
 
 
 
 
83ccdae
 
 
efaf91a
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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()