summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVitiko <[email protected]>2023-09-18 15:14:22 -0400
committerVitiko <[email protected]>2023-09-18 15:15:36 -0400
commitb9648172ba4e5599350b408bad6a5fe54c082129 (patch)
tree3c9c4cdaae77a223928cbb1d71b68f6039bad7af
parent17add7fbb3ae1919a40d505470d499d46df9ae6b (diff)
downloadbazarr-b9648172ba4e5599350b408bad6a5fe54c082129.tar.gz
bazarr-b9648172ba4e5599350b408bad6a5fe54c082129.zip
Subdivx provider: improve movies matches
Add one year tolerancy for movies. False positives probability is low enough to do so. (Fix #2245)
-rw-r--r--libs/subliminal_patch/providers/subdivx.py10
-rw-r--r--tests/subliminal_patch/test_subdivx.py10
2 files changed, 19 insertions, 1 deletions
diff --git a/libs/subliminal_patch/providers/subdivx.py b/libs/subliminal_patch/providers/subdivx.py
index 6bdc58eb0..4f473e773 100644
--- a/libs/subliminal_patch/providers/subdivx.py
+++ b/libs/subliminal_patch/providers/subdivx.py
@@ -29,6 +29,7 @@ _CLEAN_TITLE_RES = [
_SPANISH_RE = re.compile(r"españa|ib[eé]rico|castellano|gallego|castilla")
_YEAR_RE = re.compile(r"(\(\d{4}\))")
+_YEAR_RE_INT = re.compile(r"\((\d{4})\)")
_SERIES_RE = re.compile(
@@ -351,7 +352,14 @@ def _check_episode(video, title):
def _check_movie(video, title):
- if str(video.year) not in title:
+ try:
+ year = int(_YEAR_RE_INT.search(title).group(1)) # type: ignore
+ except (AttributeError, ValueError):
+ logger.debug("Year not found in title (%s). Discarding movie", title)
+ return False
+
+ if video.year and abs(year - video.year) > 1:
+ logger.debug("Year not matching: %s -> %s", year, video.year)
return False
aka_split = re.split("aka", title, flags=re.IGNORECASE)
diff --git a/tests/subliminal_patch/test_subdivx.py b/tests/subliminal_patch/test_subdivx.py
index 33f938766..708b3715a 100644
--- a/tests/subliminal_patch/test_subdivx.py
+++ b/tests/subliminal_patch/test_subdivx.py
@@ -26,6 +26,15 @@ def test_list_subtitles_movie_with_year_fallback(movies):
assert provider.list_subtitles(item, {Language("spa", "MX")})
+def test_list_subtitles_movie_with_one_difference_year(movies):
+ item = list(movies.values())[0]
+ item.title = "Sisu"
+ item.year = 2023
+
+ with SubdivxSubtitlesProvider() as provider:
+ assert provider.list_subtitles(item, {Language("spa", "MX")})
+
+
def test_handle_multi_page_search(episodes):
with SubdivxSubtitlesProvider() as provider:
for _ in provider._handle_multi_page_search(
@@ -74,6 +83,7 @@ def test_list_subtitles_episode_with_title_only_fallback(episodes):
subtitles = provider.list_subtitles(item, {Language("spa", "MX")})
assert len(subtitles) > 2
+
def test_list_subtitles_episode_with_episode_title_fallback(episodes):
item = list(episodes.values())[0]
item.series = "30 for 30"