Skip to content

Commit

Permalink
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bazarr/subtitles/indexer/utils.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 12 additions & 2 deletions custom_libs/subliminal_patch/core.py
Original file line number Diff line number Diff line change
@@ -49,7 +49,17 @@

_POOL_LIFETIME = datetime.timedelta(hours=12)

HI_REGEX = re.compile(r'[*¶♫♪].{3,}[*¶♫♪]|[\[\(\{].{3,}[\]\)\}](?<!{\\an\d})')
HI_REGEX_WITHOUT_PARENTHESIS = re.compile(r'[*¶♫♪].{3,}[*¶♫♪]|[\[\{].{3,}[\]\}](?<!{\\an\d})')
HI_REGEX_WITH_PARENTHESIS = re.compile(r'[*¶♫♪].{3,}[*¶♫♪]|[\[\(\{].{3,}[\]\)\}](?<!{\\an\d})')

HI_REGEX_PARENTHESIS_EXCLUDED_LANGUAGES = ['ara']


def parse_for_hi_regex(subtitle_text, alpha3_language):
if alpha3_language in HI_REGEX_PARENTHESIS_EXCLUDED_LANGUAGES:
return bool(re.search(HI_REGEX_WITHOUT_PARENTHESIS, subtitle_text))
else:
return bool(re.search(HI_REGEX_WITH_PARENTHESIS, subtitle_text))


def remove_crap_from_fn(fn):
@@ -1203,7 +1213,7 @@ def save_subtitles(file_path, subtitles, single=False, directory=None, chmod=Non
continue

# create subtitle path
if subtitle.text and bool(re.search(HI_REGEX, subtitle.text)):
if subtitle.text and parse_for_hi_regex(subtitle_text=subtitle.text, alpha3_language=subtitle.language.alpha3):
subtitle.language.hi = True
subtitle_path = get_subtitle_path(file_path, None if single else subtitle.language,
forced_tag=subtitle.language.forced,

0 comments on commit eb084ab

Please sign in to comment.