diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py index 21bf7925e..c89bdd963 100644 --- a/bazarr/list_subtitles.py +++ b/bazarr/list_subtitles.py @@ -13,7 +13,6 @@ from subliminal import core from subliminal_patch import search_external_subtitles from subzero.language import Language from bs4 import UnicodeDammit -from itertools import islice from get_args import args from database import database @@ -88,10 +87,9 @@ def store_subtitles(file): if os.path.splitext(subtitle)[1] != ".sub": logging.debug("BAZARR falling back to file content analysis to detect language.") with open(os.path.join(os.path.dirname(file), subtitle), 'r') as f: - text = list(islice(f, 100)) - text = ' '.join(text) - encoding = UnicodeDammit(text) + text = f.read() try: + encoding = UnicodeDammit(text) text = text.decode(encoding.original_encoding) detected_language = langdetect.detect(text) except Exception as e: @@ -186,10 +184,9 @@ def store_subtitles_movie(file): if os.path.splitext(subtitle)[1] != ".sub": logging.debug("BAZARR falling back to file content analysis to detect language.") with open(os.path.join(os.path.dirname(file), dest_folder, subtitle), 'r') as f: - text = list(islice(f, 100)) - text = ' '.join(text) - encoding = UnicodeDammit(text) + text = f.read() try: + encoding = UnicodeDammit(text) text = text.decode(encoding.original_encoding) detected_language = langdetect.detect(text) except Exception as e: @@ -408,7 +405,7 @@ def guess_external_subtitles(dest_folder, subtitles): logging.debug("BAZARR falling back to file content analysis to detect language.") detected_language = None with open(subtitle_path, 'r') as f: - text = ' '.join(list(islice(f, 100))) + text = f.read() try: encoding = UnicodeDammit(text) text = text.decode(encoding.original_encoding)