# VERSION: 1.0 # AUTHORS: LightDestory (https://github.com/LightDestory) import re from helpers import download_file, retrieve_url from novaprinter import prettyPrinter from time import sleep from datetime import datetime class nyaa(object): url = "https://nyaa.si/" name = "Nyaa" supported_categories = { "all": "0_0", "movies": "4_0", "music": "2_0", "games": "6_2", "anime": "1_0", "software": "6_1", "books": "3_0", "pictures": "5_0", } class HTMLParser: def __init__(self, url): self.url = url self.noTorrents = False def feed(self, html): self.noTorrents = False torrents = self.__findTorrents(html) if len(torrents) == 0: self.noTorrents = True return for torrent in range(len(torrents)): data = { "link": torrents[torrent][0], "name": torrents[torrent][1], "size": torrents[torrent][2], "seeds": torrents[torrent][3], "leech": torrents[torrent][4], "engine_url": self.url, "desc_link": torrents[torrent][5], "pub_date": torrents[torrent][6], } prettyPrinter(data) def __findTorrents(self, html): torrents = [] trs = re.findall(r"