def test_basic(self): results = [ nyaa.search()[0], nyaa.search('horrible subs', 2, order='-seeders')[0], nyaa.search('horrible subs', 1, order='seeders')[0], nyaa.search('fate stay night', 1, user=64513)[0], ] assert results[0].title != '' assert results[1].seeders > 0 assert results[2].seeders == 0 assert results[3].title != ''
async def nyaa(self, message): if "search" in message.content: search = message.content[12:] await self.send_message(message.channel, "https://www.nyaa.se/?page=search&term=" + search + "&sort=2") search = "720" mess = message.content[5:] search += mess search = nyaa.search(search, user=64513)[0] await self.send_message(message.channel, search.link)
def handle(self, *args, **kwargs): results = [] for fansub, users in tqdm(NYAA_USERS.items()): f,_ = Fansub.objects.get_or_create(name=fansub) for user in users: offset = 1 while True: results_ = nyaa.search(user=user,offset=offset) if not results_: break offset +=1 results+=results_ for res in tqdm(results): flag_next = False for j in BYPASS: if j.lower() in res.title.lower(): flag_next = True break if flag_next: continue date = make_aware(res.date, is_dst=False) torrent,created = Torrent.objects.get_or_create(full=res.title, url=res.link.replace("download","view"), defaults=dict(download_url = res.link.replace("view","download"), date=date)) tqdm.write("%s %s " % (res.title, res.link )) full = res.title data = guessit.guessit(full, {"episode_prefer_number":True, 'expected_group':RELEASE_GROUPS}) title = data.get("title") kwargs_ = {} if title in MAL_ANIMES: search_title, mal_id = MAL_ANIMES[title] title = search_title kwargs_ = {'mal_id':mal_id} try: mal_data = mal(title,**kwargs_) except: continue anime,_ = Anime.objects.get_or_create(slug=slugify(data.get("title")), defaults={"title":data.get("title")}) release_group,_ = ReleaseGroup.objects.get_or_create(name=data.get("release_group")) mal_obj, _ = MALMeta.objects.get_or_create(mal_id=mal_data.id) mal_obj.title = mal_data.title mal_obj.image = mal_data.img mal_obj.synopsys = mal_data.synopsys mal_obj.resumen = mal_data.resumen mal_obj.synonyms = mal_data.synonyms mal_obj.title_en = mal_data.title_en mal_obj.status = mal_data.status mal_obj.save() meta,_ = MetaTorrent.objects.get_or_create( anime=anime, torrent=torrent, release_group=release_group, mal=mal_obj) meta.episode=data.get("episode", data.get("episode_title")) meta.format=data.get("format", data.get("screen_size")) meta.save()
def main(): for fansub, user_id in nyaa_users.items(): result = nyaa.search(user=user_id,offset=2) map(fetch_fansub, result)