Skip to content

Commit

Permalink
Fixed translation exception on malformed subtitles file. #1672
Browse files Browse the repository at this point in the history
  • Loading branch information
morpheus65535 committed Jan 16, 2022
1 parent 75d73cf commit 3b3d6fe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bazarr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,19 @@ def translate_subtitles_file(video_path, source_srt_file, to_lang, forced, hi):
lang_obj.alpha2)
).translate(text=block_str)
except Exception:
logging.exception(f'BAZARR Unable to translate subtitles {source_srt_file}')
return False
else:
translated_partial_srt_list = translated_partial_srt_text.split('\n\n\n')
translated_lines_list += translated_partial_srt_list

logging.debug('BAZARR saving translated subtitles to {}'.format(dest_srt_file))
for i, line in enumerate(subs):
line.plaintext = translated_lines_list[i]
try:
line.plaintext = translated_lines_list[i]
except IndexError:
logging.error(f'BAZARR is unable to translate malformed subtitles: {source_srt_file}')
return False
subs.save(dest_srt_file)

return dest_srt_file
Expand Down

0 comments on commit 3b3d6fe

Please sign in to comment.