<spoiler title="Исправленный вариант">
import re
clear_lines = []
file_eng = "eng.srt"
file_rus = "rus.srt"
file_all = "all.srt"
with open(file_eng, 'r') as file:
lines = file.readlines()
for sub in lines:
if re.match("(^\\d+\\n)", sub):
clear_lines.append(sub)
if "-->" in sub:
clear_lines.append(sub)
def insert_srt(file_srt, pos, inc):
i = 0
with open(file_srt, 'r') as file:
lines = file.readlines()
for sub in lines:
if not re.match("(^\\d+\\n)", sub):
if "-->" in sub:
if not re.match("(^\\n)", lines[i+2]):
clear_lines.insert(pos, lines[i + 2]+'\n')
else:
clear_lines.insert(pos, '\n')
if "-->" not in lines[i + 1] and not re.match("(^\\n)", lines[i+1]):
clear_lines.insert(pos, lines[i + 1])
else:
pass
pos += inc
if i < len(lines) - 3:
i += 1
insert_srt(file_eng, 2, 4)
insert_srt(file_rus, 4, 6)
with open(file_all, 'w') as file:
for line in clear_lines:
file.write(line)
</spoiler>