mirror of
https://github.com/morpheus65535/bazarr
synced 2025-02-13 09:45:26 +00:00
Subf2m Provider: improve series title matches
This commit is contained in:
parent
1ba9404129
commit
d6883c2c73
2 changed files with 21 additions and 16 deletions
|
@ -117,7 +117,9 @@ class Subf2mProvider(Provider):
|
|||
provider_name = "subf2m"
|
||||
|
||||
_movie_title_regex = re.compile(r"^(.+?)( \((\d{4})\))?$")
|
||||
_tv_show_title_regex = re.compile(r"^(.+?) - (.*?) (season|series)( \((\d{4})\))?$")
|
||||
_tv_show_title_regex = re.compile(
|
||||
r"^(.+?) [-\(]\s?(.*?) (season|series)\)?( \((\d{4})\))?$"
|
||||
)
|
||||
_supported_languages = {}
|
||||
_supported_languages["brazillian-portuguese"] = Language("por", "BR")
|
||||
|
||||
|
@ -201,7 +203,7 @@ class Subf2mProvider(Provider):
|
|||
logger.debug("Movie found: %s", results[0])
|
||||
return found_movie
|
||||
|
||||
def _search_tv_show_season(self, title, season):
|
||||
def _search_tv_show_season(self, title, season, year=None):
|
||||
try:
|
||||
season_str = _SEASONS[season - 1].lower()
|
||||
except IndexError:
|
||||
|
@ -225,11 +227,13 @@ class Subf2mProvider(Provider):
|
|||
match_season = match.group(2)
|
||||
|
||||
# Match "complete series" titles as they usually contain season packs
|
||||
if season_str == match_season or match_season == "complete":
|
||||
if season_str == match_season or "complete" in match_season:
|
||||
plus = 0.1 if year and str(year) in text else 0
|
||||
results.append(
|
||||
{
|
||||
"href": result.get("href"),
|
||||
"similarity": SequenceMatcher(None, title, match_title).ratio(),
|
||||
"similarity": SequenceMatcher(None, title, match_title).ratio()
|
||||
+ plus,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -28,22 +28,23 @@ def test_search_movie(movies, title, year, expected_url):
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"title,season,expected_url",
|
||||
"series_title,season,year,expected_url",
|
||||
[
|
||||
("Breaking Bad", 1, "/subtitles/breaking-bad-first-season"),
|
||||
("House Of The Dragon", 1, "/subtitles/house-of-the-dragon-first-season"),
|
||||
("The Bear", 1, "/subtitles/the-bear-first-season"),
|
||||
("Courage the Cowardly Dog", 1, "/subtitles/courage-the-cowardly-dog"),
|
||||
("Breaking Bad", 1, None, "/subtitles/breaking-bad-first-season"),
|
||||
("House Of The Dragon", 1, None, "/subtitles/house-of-the-dragon-first-season"),
|
||||
("The Bear", 1, None, "/subtitles/the-bear-first-season"),
|
||||
("Courage the Cowardly Dog", 1, None, "/subtitles/courage-the-cowardly-dog"),
|
||||
(
|
||||
"The Twilight Zone",
|
||||
2,
|
||||
1959,
|
||||
"/subtitles/the-twilight-zone-the-complete-original-series",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_search_tv_show_season(episodes, title, season, expected_url):
|
||||
episode = list(episodes.values())[0]
|
||||
episode.name = title
|
||||
episode.series = title
|
||||
episode.season = season
|
||||
|
||||
def test_search_tv_show_season(series_title, season, year, expected_url):
|
||||
with Subf2mProvider() as provider:
|
||||
result = provider._search_tv_show_season(episode.series, episode.season)
|
||||
result = provider._search_tv_show_season(series_title, season, year)
|
||||
assert result == expected_url
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue