aboutsummaryrefslogtreecommitdiffhomepage
path: root/custom_libs/subliminal_patch/providers/utils.py
diff options
context:
space:
mode:
authorJayZed <[email protected]>2024-09-29 21:05:46 -0400
committerJayZed <[email protected]>2024-09-29 21:05:46 -0400
commitc2a1e4d62c1bbb372127a78e4419a96d3c00e81c (patch)
treeaf19b97bbb71b514ef39928e55769fa85064e23a /custom_libs/subliminal_patch/providers/utils.py
parent4cc6806193127f9d6d3f2dab26969471d9bbf159 (diff)
parent0200bb96d98127ee32b6b66f8d6b9e21d4571a4d (diff)
downloadbazarr-c2a1e4d62c1bbb372127a78e4419a96d3c00e81c.tar.gz
bazarr-c2a1e4d62c1bbb372127a78e4419a96d3c00e81c.zip
Merge branch 'development' of https://github.com/morpheus65535/bazarr into developmentv1.4.5-beta.7
Diffstat (limited to 'custom_libs/subliminal_patch/providers/utils.py')
-rw-r--r--custom_libs/subliminal_patch/providers/utils.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/custom_libs/subliminal_patch/providers/utils.py b/custom_libs/subliminal_patch/providers/utils.py
index 2feaecea2..206334462 100644
--- a/custom_libs/subliminal_patch/providers/utils.py
+++ b/custom_libs/subliminal_patch/providers/utils.py
@@ -65,7 +65,7 @@ def _get_matching_sub(
guess = guessit(sub_name, options=guess_options)
matched_episode_num = guess.get("episode")
- if matched_episode_num:
+ if not matched_episode_num:
logger.debug("No episode number found in file: %s", sub_name)
if episode_title is not None:
@@ -86,11 +86,13 @@ def _get_matching_sub(
return None
-def _analize_sub_name(sub_name: str, title_):
- titles = re.split(r"[.-]", os.path.splitext(sub_name)[0])
+def _analize_sub_name(sub_name: str, title_: str):
+ titles = re.split(r"[\s_\.\+]?[.-][\s_\.\+]?", os.path.splitext(sub_name)[0])
+
for title in titles:
title = title.strip()
- ratio = SequenceMatcher(None, title, title_).ratio()
+ ratio = SequenceMatcher(None, title.lower(), title_.lower()).ratio()
+
if ratio > 0.85:
logger.debug(
"Episode title matched: '%s' -> '%s' [%s]", title, sub_name, ratio