1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2025-01-03 05:25:28 +00:00

Fixed opensubtitles.com provider year matching process.

This commit is contained in:
morpheus65535 2023-03-27 20:15:19 -04:00
parent 17e62f2d29
commit ef67cd4792

View file

@ -55,7 +55,7 @@ class OpenSubtitlesComSubtitle(Subtitle):
hash_verifiable = False hash_verifiable = False
def __init__(self, language, forced, hearing_impaired, page_link, file_id, releases, uploader, title, year, def __init__(self, language, forced, hearing_impaired, page_link, file_id, releases, uploader, title, year,
hash_matched, file_hash=None, season=None, episode=None): hash_matched, file_hash=None, season=None, episode=None, imdb_match=False):
language = Language.rebuild(language, hi=hearing_impaired, forced=forced) language = Language.rebuild(language, hi=hearing_impaired, forced=forced)
self.title = title self.title = title
@ -75,6 +75,7 @@ class OpenSubtitlesComSubtitle(Subtitle):
self.hash = file_hash self.hash = file_hash
self.encoding = 'utf-8' self.encoding = 'utf-8'
self.hash_matched = hash_matched self.hash_matched = hash_matched
self.imdb_match = imdb_match
@property @property
def id(self): def id(self):
@ -88,24 +89,28 @@ class OpenSubtitlesComSubtitle(Subtitle):
if type_ == "episode": if type_ == "episode":
# series # series
matches.add('series') matches.add('series')
# year
if video.year == self.year:
matches.add('year')
# season # season
if video.season == self.season: if video.season == self.season:
matches.add('season') matches.add('season')
# episode # episode
if video.episode == self.episode: if video.episode == self.episode:
matches.add('episode') matches.add('episode')
# imdb
if self.imdb_match:
matches.add('series_imdb_id')
else: else:
# title # title
matches.add('title') matches.add('title')
# year # imdb
if video.year == self.year: if self.imdb_match:
matches.add('year') matches.add('imdb_id')
# rest is same for both groups # rest is same for both groups
# year
if video.year == self.year:
matches.add('year')
# release_group # release_group
if (video.release_group and self.releases and if (video.release_group and self.releases and
any(r in sanitize_release_group(self.releases) any(r in sanitize_release_group(self.releases)
@ -344,6 +349,11 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
else: else:
moviehash_match = False moviehash_match = False
try:
year = int(item['attributes']['feature_details']['year'])
except TypeError:
year = item['attributes']['feature_details']['year']
if len(item['attributes']['files']): if len(item['attributes']['files']):
subtitle = OpenSubtitlesComSubtitle( subtitle = OpenSubtitlesComSubtitle(
language=Language.fromietf(item['attributes']['language']), language=Language.fromietf(item['attributes']['language']),
@ -354,10 +364,11 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
releases=item['attributes']['release'], releases=item['attributes']['release'],
uploader=item['attributes']['uploader']['name'], uploader=item['attributes']['uploader']['name'],
title=item['attributes']['feature_details']['movie_name'], title=item['attributes']['feature_details']['movie_name'],
year=item['attributes']['feature_details']['year'], year=year,
season=season_number, season=season_number,
episode=episode_number, episode=episode_number,
hash_matched=moviehash_match hash_matched=moviehash_match,
imdb_match=True if imdb_id else False
) )
subtitle.get_matches(self.video) subtitle.get_matches(self.video)
subtitles.append(subtitle) subtitles.append(subtitle)