From ae731bb78b1d91b3e7f6017830c4014fae4aa6ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 13 Sep 2020 23:31:40 -0400 Subject: [PATCH] Fix for missing subtitles management after implementing HI. --- bazarr/list_subtitles.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py index 60c6d8f3a..9138aadde 100644 --- a/bazarr/list_subtitles.py +++ b/bazarr/list_subtitles.py @@ -20,6 +20,8 @@ import chardet gc.enable() +global hi_regex +hi_regex = re.compile(r'[*¶♫♪].{3,}[*¶♫♪]|[\[\(\{].{3,}[\]\)\}]') def store_subtitles(original_path, reversed_path): @@ -447,15 +449,6 @@ def guess_external_subtitles(dest_folder, subtitles): logging.exception("BAZARR subtitles file doesn't seems to be text based. Skipping this file: " + subtitle_path) else: - TAG = r"(?:\s*{\\[iusb][0-1]}\s*)*" - music = re.compile(r'[-\s>~]*[*¶♫♪]+\s*.+|.+\s*[*¶♫♪]+\s*') - brackets = re.compile(r'-?%(t)s["\']*[([][^([)\]]+?(?=[A-zÀ-ž"\'.]{3,})[^([)\]]+[)\]]["\']*[\s:]*%(t)s' - % {"t": TAG}) - - HI_list = [music, brackets] - - for item in HI_list: - if bool(re.search(item, text)): - subtitles[subtitle] = Language.rebuild(subtitles[subtitle], forced=False, hi=True) - break + if bool(re.search(hi_regex, text)): + subtitles[subtitle] = Language.rebuild(subtitles[subtitle], forced=False, hi=True) return subtitles