argenteam provider: fix null exception and improve scoring

pull/986/head
ngosang 4 years ago
parent 7bac8ae1d6
commit f3c3655dae

@ -76,9 +76,11 @@ class ArgenteamSubtitle(Subtitle):
if video.series and (sanitize(self.title) in ( if video.series and (sanitize(self.title) in (
sanitize(name) for name in [video.series] + video.alternative_series)): sanitize(name) for name in [video.series] + video.alternative_series)):
matches.add('series') matches.add('series')
# season # season
if video.season and self.season == video.season: if video.season and self.season == video.season:
matches.add('season') matches.add('season')
# episode # episode
if video.episode and self.episode == video.episode: if video.episode and self.episode == video.episode:
matches.add('episode') matches.add('episode')
@ -87,6 +89,9 @@ class ArgenteamSubtitle(Subtitle):
if video.tvdb_id and str(self.tvdb_id) == str(video.tvdb_id): if video.tvdb_id and str(self.tvdb_id) == str(video.tvdb_id):
matches.add('tvdb_id') matches.add('tvdb_id')
# year (year is not available for series, but we assume it matches)
matches.add('year')
elif isinstance(video, Movie) and self.movie_kind == 'movie': elif isinstance(video, Movie) and self.movie_kind == 'movie':
# title # title
if video.title and (sanitize(self.title) in ( if video.title and (sanitize(self.title) in (
@ -230,29 +235,29 @@ class ArgenteamProvider(Provider, ProviderSubtitleArchiveMixin):
has_multiple_ids = len(argenteam_ids) > 1 has_multiple_ids = len(argenteam_ids) > 1
for aid in argenteam_ids: for aid in argenteam_ids:
response = self.session.get(url, params={'id': aid}, timeout=10) response = self.session.get(url, params={'id': aid}, timeout=10)
response.raise_for_status() response.raise_for_status()
content = response.json() content = response.json()
imdb_id = year = None if content is not None: # eg https://argenteam.net/api/v1/episode?id=11534
returned_title = title imdb_id = year = None
if not is_episode and "info" in content: returned_title = title
imdb_id = content["info"].get("imdb") if not is_episode and "info" in content:
year = content["info"].get("year") imdb_id = content["info"].get("imdb")
returned_title = content["info"].get("title", title) year = content["info"].get("year")
returned_title = content["info"].get("title", title)
for r in content['releases']:
for s in r['subtitles']: for r in content['releases']:
movie_kind = "episode" if is_episode else "movie" for s in r['subtitles']:
page_link = self.BASE_URL + movie_kind + "/" + str(aid) movie_kind = "episode" if is_episode else "movie"
# use https and new domain page_link = self.BASE_URL + movie_kind + "/" + str(aid)
download_link = s['uri'].replace('http://www.argenteam.net/', self.BASE_URL) # use https and new domain
sub = ArgenteamSubtitle(language, page_link, download_link, movie_kind, returned_title, download_link = s['uri'].replace('http://www.argenteam.net/', self.BASE_URL)
season, episode, year, r.get('team'), r.get('tags'), sub = ArgenteamSubtitle(language, page_link, download_link, movie_kind, returned_title,
r.get('source'), r.get('codec'), content.get("tvdb"), imdb_id, season, episode, year, r.get('team'), r.get('tags'),
asked_for_release_group=video.release_group, r.get('source'), r.get('codec'), content.get("tvdb"), imdb_id,
asked_for_episode=episode) asked_for_release_group=video.release_group,
subtitles.append(sub) asked_for_episode=episode)
subtitles.append(sub)
if has_multiple_ids: if has_multiple_ids:
time.sleep(self.multi_result_throttle) time.sleep(self.multi_result_throttle)

Loading…
Cancel
Save