diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py index fb1ce476f..51c85ac15 100644 --- a/bazarr/list_subtitles.py +++ b/bazarr/list_subtitles.py @@ -438,10 +438,10 @@ def guess_external_subtitles(dest_folder, subtitles): subtitle_path = os.path.join(dest_folder, subtitle) # to improve performance, skip detection of files larger that 1M - if os.path.getsize(subtitle_path) > 1 * 1024 * 1024: - logging.debug("BAZARR subtitles file is too large to be text based. Skipping this file: " + - subtitle_path) - continue + #if os.path.getsize(subtitle_path) > 1 * 1024 * 1024: + # logging.debug("BAZARR subtitles file is too large to be text based. Skipping this file: " + + # subtitle_path) + # continue with open(subtitle_path, 'rb') as f: text = f.read() @@ -452,11 +452,12 @@ def guess_external_subtitles(dest_folder, subtitles): detector = Detector() guess = detector.detect(text) logging.debug('BAZARR detected encoding %r', guess) - text = text.decode(guess) - finally: try: - if bool(re.search(hi_regex, text)): - subtitles[subtitle] = Language.rebuild(subtitles[subtitle], forced=False, hi=True) - except TypeError: + text = text.decode(guess) + except: + # text could not be decoded with guessed encoding, we wont try to detect HI fo rthis one continue + + if bool(re.search(hi_regex, text)): + subtitles[subtitle] = Language.rebuild(subtitles[subtitle], forced=False, hi=True) return subtitles