Skip to content

Commit

Permalink
Possible fix for #1189.
Browse files Browse the repository at this point in the history
  • Loading branch information
morpheus65535 committed Nov 19, 2020
1 parent e2e5412 commit fc4f78f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions libs/subliminal_patch/providers/legendastv.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class LegendasTVSubtitle(_LegendasTVSubtitle):
def __init__(self, language, type, title, year, imdb_id, season, archive, name):
super(LegendasTVSubtitle, self).__init__(language, type, title, year, imdb_id, season, archive, name)
self.archive.content = None
self.release_info = archive.name
self.release_info = name.rstrip('.srt').split('/')[-1]
self.page_link = archive.link

def make_picklable(self):
Expand Down Expand Up @@ -185,6 +185,17 @@ def query(self, language, title, season=None, episode=None, year=None, imdb_id=N
subtitles = []
# iterate over titles
for title_id, t in titles.items():
# Skip episodes or movies if it's not what was requested
if (season and t['type'] == 'movie') or (not season and t['type'] == 'episode'):
continue

# Skip if season isn't matching
if season and season != t.get('season'):
continue

# Skip if season wasn't provided (not an episode) but one is returned by provider (wrong type)
if not season and t.get('season'):
continue

logger.info('Getting archives for title %d and language %d', title_id, language.legendastv)
archives = self.get_archives(title_id, language.legendastv, t['type'], season, episode)
Expand Down Expand Up @@ -243,12 +254,14 @@ def list_subtitles(self, video, languages):
titles = [video.series] + video.alternative_series
season = video.season
episode = video.episode
imdb = video.series_imdb_id
else:
titles = [video.title] + video.alternative_titles
imdb = video.imdb_id

for title in titles:
subtitles = [s for l in languages for s in
self.query(l, title, season=season, episode=episode, year=video.year, imdb_id=video.imdb_id)]
self.query(l, title, season=season, episode=episode, year=video.year, imdb_id=imdb)]
if subtitles:
return subtitles

Expand Down

0 comments on commit fc4f78f

Please sign in to comment.