Skip to content

Commit

Permalink
Review and fix it for Addi7ed too
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandog committed Jan 29, 2018
1 parent 58d6010 commit 58a7064
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2,809 deletions.
17 changes: 9 additions & 8 deletions subliminal/providers/addic7ed.py
Expand Up @@ -236,13 +236,7 @@ def get_show_id(self, series, year=None, country_code=None):

return show_id

def query(self, series, season, year=None, country=None):
# get the show id
show_id = self.get_show_id(series, year, country)
if show_id is None:
logger.warning('No show id found for %r (%r)', series, {'year': year, 'country': country})
return []

def query(self, show_id, series, season, year=None, country=None):
# get the page of the season of the show
logger.info('Getting the page of show id %d, season %d', show_id, season)
r = self.session.get(self.server_url + 'show/%d' % show_id, params={'season': season}, timeout=10)
Expand Down Expand Up @@ -289,11 +283,18 @@ def query(self, series, season, year=None, country=None):

def list_subtitles(self, video, languages):
titles = [video.series] + video.alternative_series
show_id = None
for title in titles:
subtitles = [s for s in self.query(title, video.season, video.year)
# get the show id
show_id = self.get_show_id(title, video.year)
if show_id is None:
continue
subtitles = [s for s in self.query(show_id, title, video.season, video.year)
if s.language in languages and s.episode == video.episode]
if subtitles:
return subtitles
if show_id is None:
logger.error('No show id found for %r', video.series)

return []

Expand Down
2 changes: 1 addition & 1 deletion subliminal/providers/tvsubtitles.py
Expand Up @@ -208,7 +208,7 @@ def list_subtitles(self, video, languages):
if subtitles:
return subtitles
if show_id is None:
logger.warning('No show id found for %r (%r)', video.series, {'year': video.year})
logger.error('No show id found for %r (%r)', video.series, {'year': video.year})

return []

Expand Down

0 comments on commit 58a7064

Please sign in to comment.