Skip to content

Commit

Permalink
fix(anistream): fallback to other version if one isn't available
Browse files Browse the repository at this point in the history
  • Loading branch information
vn-ki committed Sep 28, 2019
1 parent c879cf5 commit e6f2bc1
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions anime_downloader/sites/anistream.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,23 @@ def _scrape_episodes(self):
version = self.config.get('version', 'subbed')
soup = helpers.soupify(helpers.get(self.url))
versions = soup.select_one('.card-body').select('ul')
def get_links(version):
links = [v.attrs['href'] for v in version.select('a')][::-1]
return links
dubbed = get_links(versions[1])
subbed = get_links(versions[0])
# TODO: This should be handled more gracefully
# revist once config API is finalized
if version.lower() == 'dubbed':
version = versions[1]
choice = dubbed
other = subbed
else:
version = versions[0]
links = [v.attrs['href'] for v in version.select('a')][::-1]
return links
choice = subbed
other = dubbed
if choice:
return choice
# TODO: warn about choice not available
return other

def _scrape_metadata(self):
soup = helpers.soupify(helpers.get(self.url))
Expand Down

0 comments on commit e6f2bc1

Please sign in to comment.