summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2022-03-02 20:16:04 -0500
committermorpheus65535 <[email protected]>2022-03-02 20:16:04 -0500
commitd13bc731891d8ea211b9e5f1d95f10c4e0ba170c (patch)
tree4e4c5d50236b2f2b6a016fc68b931b01b10ffad0
parent4b84a9c64c90d8872266889443ffaa0e44465087 (diff)
downloadbazarr-d13bc731891d8ea211b9e5f1d95f10c4e0ba170c.tar.gz
bazarr-d13bc731891d8ea211b9e5f1d95f10c4e0ba170c.zip
Fixed subtitles translation when there's an empty string in the source file.v1.0.4-beta.2
-rw-r--r--bazarr/utils.py9
1 files changed, 1 insertions, 8 deletions
diff --git a/bazarr/utils.py b/bazarr/utils.py
index d16028921..b8cc700ed 100644
--- a/bazarr/utils.py
+++ b/bazarr/utils.py
@@ -465,6 +465,7 @@ def translate_subtitles_file(video_path, source_srt_file, to_lang, forced, hi):
extension='.srt', forced_tag=forced, hi_tag=hi)
subs = pysubs2.load(source_srt_file, encoding='utf-8')
+ subs.remove_miscellaneous_events()
lines_list = [x.plaintext for x in subs]
joined_lines_str = '\n\n\n'.join(lines_list)
@@ -484,11 +485,6 @@ def translate_subtitles_file(video_path, source_srt_file, to_lang, forced, hi):
logging.debug('BAZARR is sending {} blocks to Google Translate'.format(len(lines_block_list)))
for block_str in lines_block_list:
- empty_first_line = False
- if block_str.startswith('\n\n\n'):
- # This happens when the first line of text in a subtitles file is an empty string
- empty_first_line = True
-
try:
translated_partial_srt_text = GoogleTranslator(source='auto',
target=language_code_convert_dict.get(lang_obj.alpha2,
@@ -498,9 +494,6 @@ def translate_subtitles_file(video_path, source_srt_file, to_lang, forced, hi):
logging.exception(f'BAZARR Unable to translate subtitles {source_srt_file}')
return False
else:
- if empty_first_line:
- # GoogleTranslate remove new lines at the beginning of the string, so we add it back.
- translated_partial_srt_text = '\n\n\n' + translated_partial_srt_text
translated_partial_srt_list = translated_partial_srt_text.split('\n\n\n')
translated_lines_list += translated_partial_srt_list