class the_pirate_bay(object): """ the_pirate_bay module for we-get. """ def __init__(self, pargs): self.links = None self.pargs = pargs self.action = None self.search_query = None self.module = Module() self.parse_pargs() self.items = dict() def parse_pargs(self): for opt in self.pargs: if opt == "--search": self.action = "search" self.search_query = self.pargs[opt][0].replace(' ', '-') elif opt == "--list": self.action = "list" def _parse_data(self, data): data = data.replace('\t', '').replace('\n', '') items = re.findall( r'<div class=\"detName\">(.*?)<div class=\"detName\">', data) seeds = None leeches = None magnet = None for item in items: seeds, leeches = re.findall(r'<td align=\"right\">(\d+)</td>', item) magnet = re.findall(r'href=[\'"]?([^\'">]+)', item)[1] user_status = re.findall(r'<img.+title="(Trusted|VIP)"', item) try: user_status = user_status[0].lower() except IndexError: user_status = None name = self.module.fix_name(self.module.magnet2name(magnet)) self.items.update({ name: { 'seeds': seeds, 'leeches': leeches, 'link': magnet, 'user_status': user_status } }) def search(self): url = "%s%s" % (BASE_URL, SEARCH_LOC % (self.search_query)) data = self.module.http_get_request(url) self._parse_data(data) return self.items def list(self): url = "%s%s" % (BASE_URL, LIST_LOC) data = self.module.http_get_request(url) self._parse_data(data) return self.items
class yts(object): """ yts module using the JSON API. """ def __init__(self, pargs): self.links = None self.pargs = pargs self.action = None self.quality = "720p" self.genre = "all" self.search_query = None self.module = Module() self.parse_pargs() self.items = dict() def parse_pargs(self): for opt in self.pargs: if opt == "--search": self.action = "search" self.search_query = self.pargs[opt][0].replace(' ', '-') elif opt == "--list": self.action = "list" elif opt == "--quality": self.quality = self.pargs[opt][0] elif opt == "--genre": self.genre = self.pargs[opt][0] def search(self): url = "%s%s" % (BASE_URL, SEARCH_LOC % (self.search_query, self.quality, self.genre)) data = json.loads(self.module.http_get_request(url)) try: api = data['data']['movies'] except KeyError: return self.items for movie in api: torrent_name = self.module.fix_name(movie['title']) seeds = movie['torrents'][0]['seeds'] leeches = movie['torrents'][0]['peers'] link = movie['torrents'][0]['url'] self.items.update( { torrent_name : { 'leeches' : leeches, 'seeds' : seeds, 'link' : link}} ) return self.items def list(self): url = "%s%s" % (BASE_URL, LIST_LOC % (self.quality, self.genre)) data = json.loads(self.module.http_get_request(url)) try: api = data['data']['movies'] except KeyError: return self.items for movie in api: torrent_name = self.module.fix_name(movie['title']) seeds = movie['torrents'][0]['seeds'] leeches = movie['torrents'][0]['peers'] link = movie['torrents'][0]['url'] self.items.update( { torrent_name : { 'leeches' : leeches, 'seeds' : seeds, 'link' : link}} ) return self.items
class eztv(object): """ eztv module for we-get. """ def __init__(self, pargs): self.links = None self.pargs = pargs self.action = None self.search_query = None self.module = Module() self.parse_pargs() self.items = dict() def parse_pargs(self): for opt in self.pargs: if opt == "--search": self.action = "search" self.search_query = self.pargs[opt][0].replace(' ', '-') elif opt == "--list": self.action = "list" def _parse_data(self, data): data = data.replace('\t', '').replace('\n', '') items = re.findall(r'<tr name=\"hover\" class=\"forum_header_border\">(.*?)</tr>', data) seeds = None leeches = None magnet = None for item in items: if "magnet:" in item: try: seeds = re.findall(r'<font color=\"green\">(.*?)</font>', item)[0] # In case seeds will be 1,212 seeds = seeds.replace(',', '') except IndexError: seeds = '0' # EZTv will not return lecches ): leeches = "?" magnet = re.findall(r'href=[\'"]?([^\'">]+)', item)[2] name = self.module.fix_name(self.module.magnet2name(magnet)) self.items.update( { name : { 'seeds' : seeds, 'leeches' : leeches, 'link' : magnet} }) def search(self): url = "%s%s" % (BASE_URL, SEARCH_LOC % (self.search_query)) data = self.module.http_get_request(url) self._parse_data(data) return self.items def list(self): url = "%s%s" % (BASE_URL, LIST_LOC) data = self.module.http_get_request(url) self._parse_data(data) return self.items
class the_pirate_bay(object): """the_pirate_bay module for we-get.""" def __init__(self, pargs): self.links = None self.pargs = pargs self.action = None self.search_query = None self.filter = "" self.module = Module() self.parse_pargs() self.items = dict() def parse_pargs(self): for opt in self.pargs: if opt == "--search": self.action = "search" self.search_query = self.pargs[opt][0].replace(" ", "-") elif opt == "--list": self.action = "list" if opt == "--sfw": self.filter = API_SFW_FILTER def generate_magnet(self, data): return f"magnet:?xt=urn:btih:{data['info_hash']}&dn={urllib.parse.quote(data['name'])}{API_TRACKERS}" def _parse_data(self, data): for row in json.loads(data): self.items.update({ row["name"]: { "seeds": row["seeders"], "leeches": row["leechers"], "link": self.generate_magnet(row), "user_status": row["status"], } }) def search(self): url = f"{API_URL}{API_SEARCH_LOC}{self.search_query}{self.filter}" data = self.module.http_get_request(url) self._parse_data(data) return self.items def list(self): url = f"{API_URL}{ALI_LIST_LOC}" data = self.module.http_get_request(url) self._parse_data(data) return self.items
class leetx(object): """ 1337x module for we-get. """ def __init__(self, pargs): self.links = None self.pargs = pargs self.action = None self.search_query = None self.module = Module() self.parse_pargs() self.items = dict() self.results = 10 # Limit the results to avoid blocking. def parse_pargs(self): for opt in self.pargs: if opt == "--search": self.action = "search" self.search_query = self.pargs[opt][0] elif opt == "--list": self.action = "list" def set_item(self, link): url = "%s%s" % (BASE_URL, link) magnet = None data = self.module.http_get_request(url) links = re.findall(r'href=[\'"]?([^\'">]+)', data) seeders = re.findall(r'<span class=\"seeds\">(.*?)</span>', data)[0] leechers = re.findall(r'<span class=\"leeches\">(.*?)</span>', data)[0] item = dict() name = None for link in links: if "magnet" in link: magnet = link break name = self.module.fix_name(self.module.magnet2name(magnet)) item.update( {name: { 'seeds': seeders, 'leeches': leechers, 'link': magnet }}) return item def search(self): url = "%s%s" % (BASE_URL, SEARCH_LOC % (quote_plus(self.search_query))) data = self.module.http_get_request(url) links = re.findall(r'href=[\'"]?([^\'">]+)', data) results = 0 for link in links: if "/torrent/" in link: if results == self.results: break item = self.set_item(link) self.items.update(item) results += 1 return self.items def list(self): url = "%s%s" % (BASE_URL, LIST_LOC) data = self.module.http_get_request(url) links = re.findall(r'href=[\'"]?([^\'">]+)', data) results = 0 for link in links: if "/torrent/" in link: if results == self.results: break item = self.set_item(link) self.items.update(item) results += 1 return self.items