mirror of
https://github.com/morpheus65535/bazarr
synced 2025-02-20 21:17:02 +00:00
Fixed translation exception on malformed subtitles file. #1672
This commit is contained in:
parent
75d73cf604
commit
3b3d6fe36a
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue