summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--libs/subliminal_patch/providers/subdivx.py14
-rw-r--r--tests/subliminal_patch/test_subdivx.py13
2 files changed, 27 insertions, 0 deletions
diff --git a/libs/subliminal_patch/providers/subdivx.py b/libs/subliminal_patch/providers/subdivx.py
index 5be08e45e..0d1752dd7 100644
--- a/libs/subliminal_patch/providers/subdivx.py
+++ b/libs/subliminal_patch/providers/subdivx.py
@@ -63,6 +63,8 @@ class SubdivxSubtitle(Subtitle):
# episode
if isinstance(video, Episode):
# already matched in search query
+
+ # TODO: avoid false positive with some short/common titles
matches.update(["title", "series", "season", "episode", "year"])
# movie
@@ -106,11 +108,23 @@ class SubdivxSubtitlesProvider(Provider):
subtitles = []
if isinstance(video, Episode):
+ # TODO: cache pack queries (TV SHOW S01 / TV SHOW 2022 S01).
+ # Too many redundant server calls.
+
for query in (
f"{video.series} S{video.season:02}E{video.episode:02}",
f"{video.series} S{video.season:02}",
):
subtitles += self._handle_multi_page_search(query, video)
+
+ # Try with year
+ if len(subtitles) <= 5 and video.year:
+ logger.debug("Few results. Trying with year")
+ for query in (
+ f"{video.series} {video.year} S{video.season:02}E{video.episode:02}",
+ f"{video.series} {video.year} S{video.season:02}",
+ ):
+ subtitles += self._handle_multi_page_search(query, video)
else:
for query in (video.title, f"{video.title} ({video.year})"):
subtitles += self._handle_multi_page_search(query, video)
diff --git a/tests/subliminal_patch/test_subdivx.py b/tests/subliminal_patch/test_subdivx.py
index ae9676aee..bc932d494 100644
--- a/tests/subliminal_patch/test_subdivx.py
+++ b/tests/subliminal_patch/test_subdivx.py
@@ -52,6 +52,19 @@ def test_list_subtitles_castillian_spanish(episodes):
assert provider.list_subtitles(item, {Language.fromietf("es")})
+def test_list_subtitles_episode_with_year(episodes):
+ item = list(episodes.values())[0]
+ item.series = "The Bear"
+ item.name = "The Bear"
+ item.season = 1
+ item.episode = 1
+ item.year = 2022
+
+ with SubdivxSubtitlesProvider() as provider:
+ subtitles = provider.list_subtitles(item, {Language("spa", "MX")})
+ assert len(subtitles) > 2
+
+
def test_download_subtitle(movies):
subtitle = SubdivxSubtitle(
Language("spa", "MX"),