From fa7b9d74a8a3a28b67790199bbf76fe09a846556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 18 Nov 2019 06:48:09 -0500 Subject: [PATCH] Fix for subtitles with no language code. --- bazarr/list_subtitles.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py index 5806778a3..59ab79225 100644 --- a/bazarr/list_subtitles.py +++ b/bazarr/list_subtitles.py @@ -93,7 +93,8 @@ def store_subtitles(original_path, reversed_path): text = f.read() try: encoding = UnicodeDammit(text) - text = text.decode(encoding.original_encoding) + if six.PY2: + text = text.decode(encoding.original_encoding) detected_language = langdetect.detect(text) except Exception as e: logging.exception( @@ -184,7 +185,8 @@ def store_subtitles_movie(original_path, reversed_path): text = f.read() try: encoding = UnicodeDammit(text) - text = text.decode(encoding.original_encoding) + if six.PY2: + text = text.decode(encoding.original_encoding) detected_language = langdetect.detect(text) except Exception as e: logging.exception( @@ -403,7 +405,8 @@ def guess_external_subtitles(dest_folder, subtitles): text = f.read() try: encoding = UnicodeDammit(text) - text = text.decode(encoding.original_encoding) + if six.PY2: + text = text.decode(encoding.original_encoding) detected_language = langdetect.detect(text) except Exception as e: logging.exception('BAZARR Error trying to detect language for this subtitles file: ' +