fix(anistream): fallback to other version if one isn't available
This commit is contained in:
parent
c879cf567f
commit
e6f2bc1a20
@ -30,12 +30,23 @@ class Anistream(Anime, sitename='anistream.xyz'):
|
|||||||
version = self.config.get('version', 'subbed')
|
version = self.config.get('version', 'subbed')
|
||||||
soup = helpers.soupify(helpers.get(self.url))
|
soup = helpers.soupify(helpers.get(self.url))
|
||||||
versions = soup.select_one('.card-body').select('ul')
|
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':
|
if version.lower() == 'dubbed':
|
||||||
version = versions[1]
|
choice = dubbed
|
||||||
|
other = subbed
|
||||||
else:
|
else:
|
||||||
version = versions[0]
|
choice = subbed
|
||||||
links = [v.attrs['href'] for v in version.select('a')][::-1]
|
other = dubbed
|
||||||
return links
|
if choice:
|
||||||
|
return choice
|
||||||
|
# TODO: warn about choice not available
|
||||||
|
return other
|
||||||
|
|
||||||
def _scrape_metadata(self):
|
def _scrape_metadata(self):
|
||||||
soup = helpers.soupify(helpers.get(self.url))
|
soup = helpers.soupify(helpers.get(self.url))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user