mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-22 07:42:32 +00:00
Subdivx provider: improve movies matches
Add one year tolerancy for movies. False positives probability is low enough to do so. (Fix #2245)
This commit is contained in:
parent
17add7fbb3
commit
b9648172ba
2 changed files with 19 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue