mirror of https://github.com/morpheus65535/bazarr
Fixed translation exception on malformed subtitles file. #1672
This commit is contained in:
parent
75d73cf604
commit
3b3d6fe36a
|
@ -486,6 +486,7 @@ def translate_subtitles_file(video_path, source_srt_file, to_lang, forced, hi):
|
||||||
lang_obj.alpha2)
|
lang_obj.alpha2)
|
||||||
).translate(text=block_str)
|
).translate(text=block_str)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
logging.exception(f'BAZARR Unable to translate subtitles {source_srt_file}')
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
translated_partial_srt_list = translated_partial_srt_text.split('\n\n\n')
|
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))
|
logging.debug('BAZARR saving translated subtitles to {}'.format(dest_srt_file))
|
||||||
for i, line in enumerate(subs):
|
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)
|
subs.save(dest_srt_file)
|
||||||
|
|
||||||
return dest_srt_file
|
return dest_srt_file
|
||||||
|
|
Loading…
Reference in New Issue