From 3b3d6fe36aa33defa694e083713e78c0e4e84cb8 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Sun, 16 Jan 2022 11:44:47 -0500 Subject: [PATCH] Fixed translation exception on malformed subtitles file. #1672 --- bazarr/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bazarr/utils.py b/bazarr/utils.py index f75776d37..0a41d32d3 100644 --- a/bazarr/utils.py +++ b/bazarr/utils.py @@ -486,6 +486,7 @@ 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') @@ -493,7 +494,11 @@ def translate_subtitles_file(video_path, source_srt_file, to_lang, forced, hi): 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