Скрип выполняет соединение субтитров rus и eng.
f1 = open('file_eng.srt','r')
f2 = open('file_rus.srt','r')
fin = open('file_all.srt','w')
s = list(f1.readlines())
s1 = list(f2.readlines())
s3=[]
k=1
for i in s:
for j in s1:
if len(i)>4 and len(j)>4 and i==j and '00' in i and '00' in j:
s3.append(str(k)+'\n')
s3.append(i)
k+=1
#print (s3)
l=2
k=0
j=1
while j<len(s):
if (len(s[k])>4 and len(s[j])>4 or not s[k].replace('\n','').isdigit() and not s[j].replace('\n','').isdigit()) and '00' not in s[k] and s[k] not in s3[l-4:l]:
#print (i.replace('\n',''))
if (len(s[k])>4 and len(s[j])>4 or not s[k].replace('\n','').isdigit() and not s[j].replace('\n','').isdigit()) and '00' not in s[j]:
s3.insert(l, s[j])
# else:
# s3.insert(l, '.')
s3.insert(l, s[k])
l += 4
k += 1
j += 1
if (len(s[-1])>4 or not s[-1].replace('\n','').isdigit()) and '00' not in s[-1]:
s3.append(s[-1])
if (len(s[-2])>4 or not s[-2].replace('\n','').isdigit())and '00' not in s[-2]:
s3.append(s[-2])
l=4
k=0
j=1
while j<len(s1):
if (len(s1[k])>4 and len(s1[j])>4 or not s1[k].replace('\n','').isdigit() and not s1[j].replace('\n','').isdigit()) and '00' not in s1[k] and s1[k] not in s3[l-6:l]:
#print (i.replace('\n',''))
s3.insert(l, '\n')
if (len(s1[k])>4 and len(s1[j])>4 or not s1[k].replace('\n','').isdigit() and not s1[j].replace('\n','').isdigit()) and '00' not in s1[j]:
s3.insert(l, s1[j])
#else:
# s3.insert(l, '.')
s3.insert(l, s1[k])
l += 7
k += 1
j += 1
if (len(s1[-1])>4 or not s1[-1].replace('\n','').isdigit()) and '00' not in s1[-1]:
s3.append(s1[-1])
if (len(s1[-2])>4 or not s1[-2].replace('\n','').isdigit())and '00' not in s1[-2]:
s3.append(s1[-2])
for i in s3:
fin.write(i)
f1.close()
f2.close()
fin.close()
Сделано наспех, сначала выдираем тайминги, после вставляем слова.