From 76a6d21b762c8bef5afbe377a1ab5f3ed71a8e8b Mon Sep 17 00:00:00 2001 From: NotTsunami <4589807+NotTsunami@users.noreply.github.com> Date: Sun, 12 Jan 2020 14:25:34 -0500 Subject: [PATCH] Destroyed Torrentbutler.py (markdown) --- Torrentbutler.py.md | 73 --------------------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 Torrentbutler.py.md diff --git a/Torrentbutler.py.md b/Torrentbutler.py.md deleted file mode 100644 index ec6a6fa..0000000 --- a/Torrentbutler.py.md +++ /dev/null @@ -1,73 +0,0 @@ - # -*- coding: utf-8 -*- - #VERSION: 1.0 - #AUTHOR: robsoalvs - - #Copyleft - - from novaprinter import prettyPrinter - import urllib2, tempfile, sgmllib, os - - class torrentbutler(object): - url = "http://www.torrentbutler.eu/" - name = " torrentbutler (english)" - supported_categories = {"all": "", "books": "ebook/", "movies": "films/", "tv": "series/", "music": "musique/", "software": "logiciels/", "games": ""} - - def __init__(self): - self.results = [] - self.parser = self.SimpleSGMLParser(self.results, self.url) - - def download_torrent(self, url): - file, path = tempfile.mkstemp(".torrent") - file = os.fdopen(file, "wb") - dat = urllib2.urlopen(urllib2.Request(url, headers={"User-Agent" : "Mozilla/5.0"} )).read() - file.write(dat) - file.close() - print path+" "+url - - class SimpleSGMLParser(sgmllib.SGMLParser): - def __init__(self, results, url, *args): - sgmllib.SGMLParser.__init__(self) - self.url = url - self.data_counter = None - self.current_item = None - self.results = results - - def start_a(self, attr): - params = dict(attr) - if params.has_key("href") and params["href"].startswith("http://www.torrentbutler.eu/dl-torrent"): - self.current_item = {} - self.data_counter = 0 - self.current_item["desc_link"]=params["href"].strip() - self.current_item["link"] = "http://www.torrentbutler.eu/dl_torrent.php?permalien="+str(params["href"].strip().split("/")[6].split(".")[0]) - - def handle_data(self, data): - if isinstance(self.data_counter,int): - self.data_counter += 1 - if self.data_counter == 3: - self.current_item["name"] = data.strip() - elif self.data_counter == 6: - self.current_item["size"] = data.strip() - elif self.data_counter == 10: - self.current_item["seeds"] = data.strip() - elif self.data_counter == 12: - self.current_item["leech"] = data.strip() - self.current_item["engine_url"] = self.url - self.data_counter = None - prettyPrinter(self.current_item) - self.results.append("a") - - def search(self, what, cat="all"): - i = 0 - while i<50: - results = [] - parser = self.SimpleSGMLParser(results, self.url) - if cat == "games": - dat = urllib2.urlopen(urllib2.Request(self.url+"/recherche/jeux-pc/%s/page-%d,trie-seeds-d"%(what, i), headers={"User-Agent" : "Mozilla/5.0"} )).read().replace(" & ", " et ") - dat += urllib2.urlopen(urllib2.Request(self.url+"/recherche/jeux-consoles/%s/page-%d,trie-seeds-d"%(what, i), headers={"User-Agent" : "Mozilla/5.0"} )).read().replace(" & ", " et ") - else: - dat = urllib2.urlopen(urllib2.Request(self.url+"/recherche/%s%s/page-%d,trie-seeds-d"%(self.supported_categories[cat], what, i), headers={"User-Agent" : "Mozilla/5.0"} )).read().replace(" & ", " et ") - parser.feed(dat) - parser.close() - if len(results) <= 0: - break - i += 1