And so usually i will have some problems downloading movies for my dad.
My dad have strict criteria for those movies.
They must be high res ( 480p and above ) and MUST Have chinese subtitles as his "english" isnt that great....
And which movies usually has chinese subtitles?
Not a lot....
And so, there is a need for the english subtitles to be translated to chinese and "hopefully" be playable in his VLC.
But the translated "chinese" file converted using google translate is unable to play well... because there seems to be font error on the timecode... so... here is a "tested only once" script that seems to work...
=== CODE ===
#!/usr/bin/python
import sys
with open("english.srt") as f:
english_content = f.readlines()
with open("chinese.srt") as f:
chinese_content = f.readlines()
#print english_content[0]
#print english_content[1]
#print english_content[2]
#print chinese_content[2]
def keeporthrow(mystring):
try:
int(mystring[0])
return True
except ValueError:
return False
#print keeporthrow(english_content[1])
#print keeporthrow(english_content[2])
if (len(english_content) != len(chinese_content)):
print "English file: " + str(len(english_content))
print "Chinese file: " + str(len(chinese_content))
print "Rows count dont match!"
exit
for i in range(0,len(english_content)):
#for i in range(0,10):
if keeporthrow(english_content[i]):
print english_content[i].rstrip('\n')
else:
if len(chinese_content[i]) == 1:
sys.stdout.write("\r\n")
else:
print chinese_content[i].rstrip('\n')
=== CODE ===
No comments:
Post a Comment