From eb084abc21b3d37390d6ec70d73e62297032f7c3 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Sun, 25 Aug 2024 15:05:31 -0400 Subject: [PATCH] Fixed hearing-impaired detection using regex when language is Arabic and parenthesis are included in text. #2612 --- bazarr/subtitles/indexer/utils.py | 2 +- custom_libs/subliminal_patch/core.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/bazarr/subtitles/indexer/utils.py b/bazarr/subtitles/indexer/utils.py index 03549d748..222a66a8f 100644 --- a/bazarr/subtitles/indexer/utils.py +++ b/bazarr/subtitles/indexer/utils.py @@ -136,6 +136,6 @@ def guess_external_subtitles(dest_folder, subtitles, media_type, previously_inde continue text = text.decode(encoding) - if bool(re.search(core.HI_REGEX, text)): + if core.parse_for_hi_regex(subtitle_text=text, alpha3_language=language.alpha3): subtitles[subtitle] = Language.rebuild(subtitles[subtitle], forced=False, hi=True) return subtitles diff --git a/custom_libs/subliminal_patch/core.py b/custom_libs/subliminal_patch/core.py index c1629496b..f0d7f3618 100644 --- a/custom_libs/subliminal_patch/core.py +++ b/custom_libs/subliminal_patch/core.py @@ -49,7 +49,17 @@ SUBTITLE_EXTENSIONS = ('.srt', '.sub', '.smi', '.txt', '.ssa', '.ass', '.mpl', ' _POOL_LIFETIME = datetime.timedelta(hours=12) -HI_REGEX = re.compile(r'[*¶♫♪].{3,}[*¶♫♪]|[\[\(\{].{3,}[\]\)\}](?