Skip to content

Commit

Permalink
increase speed
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullahM0hamed committed Oct 14, 2020
1 parent 90d6716 commit 0c3a5c4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion anime_downloader/sites/nyaa.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class Nyaa(Anime, sitename='nyaa'):

@classmethod
def search_episodic(cls, query, scrape_eps=False):
# Specifying an episode drastically reduces results
# and boosts the speed of this search method tremendously
# but for _scrape_episodes_episodic it won't catch all the episodes if we do that
# And thw query will already be precise and thus much faster
# than a user search
query = f"{query} 01" if not scrape_eps else query
parameters = {"f": 2, "c": "1_0", "q": query}
soup = helpers.soupify(helpers.get("https://nyaa.si", params=parameters))
links_and_titles = [(x.get("title"), x.get("href")) for x in soup.select("td[colspan] > a[href][title]:not(.comments)")]
Expand Down Expand Up @@ -141,8 +147,9 @@ def _scrape_episodes_episodic(self):

if not regexed_quality:
logger.warn("Could not discern quality, downloading all links...")
return cleaned_list

final_list = [x for x in cleaned_list if regexed_quality in x[0]]
final_list = [x for x in cleaned_list if regexed_quality.group(1) in x[0]]

return final_list

Expand Down

0 comments on commit 0c3a5c4

Please sign in to comment.