Skip to content

Instantly share code, notes, and snippets.



Created Oct 12, 2014
What would you like to do?
#!/usr/bin/env python3
import re
import sys
prog = re.compile(r"\\N(?:{[^{}]*})?")
prog2 = re.compile(r"(Dialogue: \w*,\w*:\w*:\w*.\w*,\w*:\w*:\w*.\w*,\w*,\w*,\w*,\w*,\w*,\w*,)(.*)")
for line in sys.stdin:
if line.startswith("Dialogue"):
mt = prog2.match(line)
if mt and len(mt.groups()) == 2:
a, b = mt.groups()
sp = prog.split(b)
if len(sp) == 2:
print((a+sp[0]).strip(), file=sys.stderr)
print((a+sp[1]).strip(), file=sys.stdout)
print(line.strip(), file=sys.stderr)
if not re.findall(r'[\u4e00-\u9fff]+', line):
print(line.strip(), file=sys.stdout)
set -e
for f in ./*.ass; do
cat "$f" | python3 > "english/$f" 2> "chinese/$f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment