Improvements to OpenSubtitles.org provider.

pull/1146/head
Louis Vézina 4 years ago
parent 9d6110fd37
commit 8939bb9769

@ -43,6 +43,7 @@ class OpenSubtitlesSubtitle(_OpenSubtitlesSubtitle):
self.release_info = movie_release_name self.release_info = movie_release_name
self.wrong_fps = False self.wrong_fps = False
self.skip_wrong_fps = skip_wrong_fps self.skip_wrong_fps = skip_wrong_fps
self.movie_imdb_id = movie_imdb_id
def get_fps(self): def get_fps(self):
try: try:
@ -90,6 +91,10 @@ class OpenSubtitlesSubtitle(_OpenSubtitlesSubtitle):
self.query_parameters.get("tag", None)) self.query_parameters.get("tag", None))
matches.add("hash") matches.add("hash")
# imdb_id match so we'll consider year as matching
if self.movie_imdb_id and video.imdb_id and (self.movie_imdb_id == video.imdb_id):
matches.add("year")
return matches return matches
@ -231,13 +236,13 @@ class OpenSubtitlesProvider(ProviderRetryMixin, _OpenSubtitlesProvider):
else: else:
query = [video.title] + video.alternative_titles query = [video.title] + video.alternative_titles
return self.query(languages, hash=video.hashes.get('opensubtitles'), size=video.size, imdb_id=video.imdb_id, return self.query(video, languages, hash=video.hashes.get('opensubtitles'), size=video.size,
query=query, season=season, episode=episode, tag=video.original_name, imdb_id=video.imdb_id, query=query, season=season, episode=episode, tag=video.original_name,
use_tag_search=self.use_tag_search, only_foreign=self.only_foreign, use_tag_search=self.use_tag_search, only_foreign=self.only_foreign,
also_foreign=self.also_foreign) also_foreign=self.also_foreign)
def query(self, languages, hash=None, size=None, imdb_id=None, query=None, season=None, episode=None, tag=None, def query(self, video, languages, hash=None, size=None, imdb_id=None, query=None, season=None, episode=None,
use_tag_search=False, only_foreign=False, also_foreign=False): tag=None, use_tag_search=False, only_foreign=False, also_foreign=False):
# fill the search criteria # fill the search criteria
criteria = [] criteria = []
if hash and size: if hash and size:
@ -294,6 +299,9 @@ class OpenSubtitlesProvider(ProviderRetryMixin, _OpenSubtitlesProvider):
movie_name = _subtitle_item['MovieName'] movie_name = _subtitle_item['MovieName']
movie_release_name = _subtitle_item['MovieReleaseName'] movie_release_name = _subtitle_item['MovieReleaseName']
movie_year = int(_subtitle_item['MovieYear']) if _subtitle_item['MovieYear'] else None movie_year = int(_subtitle_item['MovieYear']) if _subtitle_item['MovieYear'] else None
if season or episode:
movie_imdb_id = 'tt' + _subtitle_item['SeriesIMDBParent']
else:
movie_imdb_id = 'tt' + _subtitle_item['IDMovieImdb'] movie_imdb_id = 'tt' + _subtitle_item['IDMovieImdb']
movie_fps = _subtitle_item.get('MovieFPS') movie_fps = _subtitle_item.get('MovieFPS')
series_season = int(_subtitle_item['SeriesSeason']) if _subtitle_item['SeriesSeason'] else None series_season = int(_subtitle_item['SeriesSeason']) if _subtitle_item['SeriesSeason'] else None
@ -321,6 +329,9 @@ class OpenSubtitlesProvider(ProviderRetryMixin, _OpenSubtitlesProvider):
if language not in languages: if language not in languages:
continue continue
if video.imdb_id and (movie_imdb_id != video.imdb_id):
continue
query_parameters = _subtitle_item.get("QueryParameters") query_parameters = _subtitle_item.get("QueryParameters")
subtitle = self.subtitle_class(language, hearing_impaired, page_link, subtitle_id, matched_by, subtitle = self.subtitle_class(language, hearing_impaired, page_link, subtitle_id, matched_by,

Loading…
Cancel
Save