aboutsummaryrefslogtreecommitdiffhomepage
path: root/custom_libs/subliminal_patch
diff options
context:
space:
mode:
authorGabbeHags <[email protected]>2024-09-02 11:19:52 +0200
committerGitHub <[email protected]>2024-09-02 05:19:52 -0400
commit92708e722f9f2706f8503cc998032ddc9daf445f (patch)
treee4abc8785943430f75728c7151ce4ed66416cda0 /custom_libs/subliminal_patch
parentdeae4e52f0eabda1a6014bafcacf3ec121b8b430 (diff)
downloadbazarr-92708e722f9f2706f8503cc998032ddc9daf445f.tar.gz
bazarr-92708e722f9f2706f8503cc998032ddc9daf445f.zip
Made all subf2m test pass (#2645)v1.4.4-beta.40
Diffstat (limited to 'custom_libs/subliminal_patch')
-rw-r--r--custom_libs/subliminal_patch/providers/subf2m.py4
-rw-r--r--custom_libs/subliminal_patch/providers/utils.py8
-rw-r--r--custom_libs/subliminal_patch/subtitle.py2
3 files changed, 8 insertions, 6 deletions
diff --git a/custom_libs/subliminal_patch/providers/subf2m.py b/custom_libs/subliminal_patch/providers/subf2m.py
index 0ef39595d..1ac0b4048 100644
--- a/custom_libs/subliminal_patch/providers/subf2m.py
+++ b/custom_libs/subliminal_patch/providers/subf2m.py
@@ -132,9 +132,9 @@ _DEFAULT_HEADERS = {
class Subf2mProvider(Provider):
provider_name = "subf2m"
- _movie_title_regex = re.compile(r"^(.+?)( \((\d{4})\))?$")
+ _movie_title_regex = re.compile(r"^(.+?)(\s+\((\d{4})\))?$")
_tv_show_title_regex = re.compile(
- r"^(.+?) [-\(]\s?(.*?) (season|series)\)?( \((\d{4})\))?$"
+ r"^(.+?)\s+[-\(]\s?(.*?)\s+(season|series)\)?(\s+\((\d{4})\))?$"
)
_tv_show_title_alt_regex = re.compile(r"(.+)\s(\d{1,2})(?:\s|$)")
_supported_languages = {}
diff --git a/custom_libs/subliminal_patch/providers/utils.py b/custom_libs/subliminal_patch/providers/utils.py
index 86fee237f..206334462 100644
--- a/custom_libs/subliminal_patch/providers/utils.py
+++ b/custom_libs/subliminal_patch/providers/utils.py
@@ -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
diff --git a/custom_libs/subliminal_patch/subtitle.py b/custom_libs/subliminal_patch/subtitle.py
index 06a491be7..c65f8cdd2 100644
--- a/custom_libs/subliminal_patch/subtitle.py
+++ b/custom_libs/subliminal_patch/subtitle.py
@@ -281,7 +281,7 @@ class Subtitle(Subtitle_):
return encoding
def is_valid(self):
- """Check if a :attr:`text` is a valid SubRip format. Note that orignal format will pypass the checking
+ """Check if a :attr:`text` is a valid SubRip format. Note that original format will bypass the checking
:return: whether or not the subtitle is valid.
:rtype: bool