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"