mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-11 01:07:36 +08:00
Fix for continue in finally not supported under Python 3.7
This commit is contained in:
parent
92bb9aa2ff
commit
9f0b6a85f0
1 changed files with 10 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue