From fb6ebf5c7a455af5f5630babcd5cc98c3c5d2820 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 25 Nov 2018 09:14:07 -0500 Subject: [PATCH] Fix for #225 when langdetect cannot recognize the language. --- bazarr/list_subtitles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py index 6dd83151e..96c91276f 100644 --- a/bazarr/list_subtitles.py +++ b/bazarr/list_subtitles.py @@ -54,10 +54,10 @@ def store_subtitles(file): encoding = UnicodeDammit(text) try: text = text.decode(encoding.original_encoding) + detected_language = langdetect.detect(text) except Exception as e: logging.exception('BAZARR Error trying to detect character encoding for this subtitles file: ' + path_replace(os.path.join(os.path.dirname(file), subtitle)) + ' You should try to delete this subtitles file manually and ask Bazarr to download it again.') else: - detected_language = langdetect.detect(text) if len(detected_language) > 0: actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) @@ -106,10 +106,10 @@ def store_subtitles_movie(file): encoding = UnicodeDammit(text) try: text = text.decode(encoding.original_encoding) + detected_language = langdetect.detect(text) except Exception as e: logging.exception('BAZARR Error trying to detect character encoding for this subtitles file: ' + path_replace_movie(os.path.join(os.path.dirname(file), subtitle)) + ' You should try to delete this subtitles file manually and ask Bazarr to download it again.') else: - detected_language = langdetect.detect(text) if len(detected_language) > 0: actual_subtitles.append([str(detected_language), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))])