Skip to content

Commit

Permalink
Merge pull request #657 from ArjixGamer/patch-31
Browse files Browse the repository at this point in the history
Voiranime: tidied up code and removed it from init.py
  • Loading branch information
AbdullahM0hamed committed Mar 26, 2021
2 parents ac070b3 + e105c19 commit 49ac322
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion anime_downloader/sites/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
('twistmoe', 'twist.moe', 'TwistMoe'),
('tenshimoe', 'tenshi.moe', 'TenshiMoe'),
('vidstream', 'vidstream', 'VidStream'),
('voiranime', 'voiranime', 'VoirAnime'),
# ('voiranime', 'voiranime', 'VoirAnime'),
('vostfree', 'vostfree', 'VostFree'),
]

Expand Down
20 changes: 13 additions & 7 deletions anime_downloader/sites/voiranime.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class VoirAnime(Anime, sitename='voiranime'):

@classmethod
def search(cls, query):
search_results = helpers.soupify(helpers.get(cls.url, params={'s': query})).select('div.item-head > h3 > a')
search_results = helpers.soupify(helpers.get(cls.url, params={'s': query})).select('.post-title > h3 > a')
search_results = [
SearchResult(
title=i.text,
Expand All @@ -23,21 +23,27 @@ def search(cls, query):
return search_results

def _scrape_episodes(self):
soup = helpers.soupify(helpers.get(self.url))
next_page = soup.select('a.ct-btn')[0].get('href')
soup = helpers.soupify(helpers.get(next_page))
episodes = soup.select('ul.video-series-list > li > a.btn-default')
return [i.get('href') for i in episodes]
html = helpers.get(self.url).text
episodes = list(re.findall(r"<li class=[\"']wp-manga-chapter *[\"']>\n<a href=[\"'](.*?)[\"']>", html))
return episodes[::-1]

def _scrape_metadata(self):
soup = helpers.soupify(helpers.get(self.url))
self.title = soup.select('div.container > h1')[0].text
self.title = soup.select_one('.post-title > h1').text


class VoirAnimeEpisode(AnimeEpisode, sitename='voiranime'):
def _get_sources(self):
base_url = 'https://voiranime.com/'
soup = helpers.soupify(helpers.get(self.url))
servers = [
base_url + x['data-redirect']
for x in soup.select('.host-select > option')
]
"""These could probably be condensed down to one, but would look too spooky"""

# code below doesnt work anymore, since voiranime introduced captcha

multilinks_regex = r'var\s*multilinks\s*=\s*\[\[{(.*?)}]];'
mutilinks_iframe_regex = r"iframe\s*src=\\(\"|')([^(\"|')]*)"
multilinks = re.search(multilinks_regex, str(soup)).group(1)
Expand Down

0 comments on commit 49ac322

Please sign in to comment.