Last active
June 24, 2019 16:38
-
-
Save coronin/06a56f71c4734a92fd90132a8a6deff1 to your computer and use it in GitHub Desktop.
I used the following to generate **Three.Seconds.zh-en.srt**
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Liang Cai, 2019-6-22 | |
import time | |
import translation | |
def translate_line(a): | |
time.sleep(1) | |
try: | |
b = translation.iciba(a, dst = 'zh') # @@@@ | |
if b.startswith('.'): | |
print b[1:], a | |
else: | |
print b, a | |
except: | |
print a | |
f = open('Three.Seconds.eng.srt', 'r') | |
c0 = 5001 # @@@@ | |
lines = f.readlines() | |
f.close() | |
newLines = [] | |
c = 0 | |
print '\n\n\n\n' | |
for l in lines: | |
line = l.strip() | |
c += 1 | |
if c < c0: | |
continue | |
if line and (line[0].isalpha() or line.startswith('...')): | |
translate_line(line) | |
elif line and line.startswith('- '): | |
print '-', | |
translate_line( line[2:] ) | |
else: | |
print line | |
if not c % 5000: | |
raise Exception, 'Please copy screen output to the srt file %d~%d' % (c0, c) | |
print ';; Done by Liang %d' % int(time.time()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment