mirror of
https://github.com/morpheus65535/bazarr.git
synced 2024-12-27 09:36:06 +08:00
Subdivx Provider: improve episode queries
This commit is contained in:
parent
d7c8188f94
commit
71fe2b7a1d
2 changed files with 27 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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"),
|
||||
|
|
Loading…
Reference in a new issue