From add29f9a5c91972674da92240166a14345934986 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 8 Jan 2013 22:24:21 +0200 Subject: [PATCH] Remove torrentdownloads.ws search plugin (Pretty much dead...) --- .../nova/engines/torrentdownloads.png | Bin 423 -> 0 bytes .../nova/engines/torrentdownloads.py | 141 ------------------ .../nova3/engines/torrentdownloads.png | Bin 423 -> 0 bytes .../nova3/engines/torrentdownloads.py | 141 ------------------ src/searchengine/search.qrc | 4 - 5 files changed, 286 deletions(-) delete mode 100644 src/searchengine/nova/engines/torrentdownloads.png delete mode 100644 src/searchengine/nova/engines/torrentdownloads.py delete mode 100644 src/searchengine/nova3/engines/torrentdownloads.png delete mode 100644 src/searchengine/nova3/engines/torrentdownloads.py diff --git a/src/searchengine/nova/engines/torrentdownloads.png b/src/searchengine/nova/engines/torrentdownloads.png deleted file mode 100644 index ce14cea487d289ace537cb4139b8f5080e39ee47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 423 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgga9zJ1R#dR;W-U3Zg_jGX#u{gbS zvcDIzp~TVosbcdEuVw$hbdL428MU*)fpNNzF=Wk_0z3E{OFv^)dlAm8J^`- z)K&OAE92wWdh2>oSx_X$v;5pa%l0N-7daQX+tt4nK2_}6yShe2NchP@OGmjiq0>2y z^qXulm=qSZ24;5$$ug!kEwxT~mht4)I`3W6625Z$-Mm`sRsO7y@P-9lO}FclXQq`I zvN7cJ>S@;pxE|Z}tLN*s%9?pSujBd{vj1w-Uu%k5bFBaS_H(RXnO{}0yj{NJwJ|Uh O89ZJ6T-G@yGywp^OsDMt diff --git a/src/searchengine/nova/engines/torrentdownloads.py b/src/searchengine/nova/engines/torrentdownloads.py deleted file mode 100644 index 0d0b79591..000000000 --- a/src/searchengine/nova/engines/torrentdownloads.py +++ /dev/null @@ -1,141 +0,0 @@ -#VERSION: 1.1 -#AUTHORS: Christophe Dumez (chris@qbittorrent.org) - -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the author nor the names of its contributors may be -# used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - - -from novaprinter import prettyPrinter -from helpers import retrieve_url -import StringIO, gzip, urllib2, tempfile -import sgmllib -import re -import os - -class torrentdownloads(object): - url = 'http://www.torrentdownloads.net' - name = 'TorrentDownloads' - supported_categories = {'all': '0', 'movies': '4', 'tv': '8', 'music': '5', 'games': '3', 'anime': '1', 'software': '7', 'books': '2'} - - def __init__(self): - self.results = [] - #self.parser = self.SimpleSGMLParser(self.results, self.url) - - def download_torrent(self, url): - """ Download file at url and write it to a file, return the path to the file and the url """ - file, path = tempfile.mkstemp() - file = os.fdopen(file, "w") - # Download url - req = urllib2.Request(url) - response = urllib2.urlopen(req) - dat = response.read() - # Check if it is gzipped - if dat[:2] == '\037\213': - # Data is gzip encoded, decode it - compressedstream = StringIO.StringIO(dat) - gzipper = gzip.GzipFile(fileobj=compressedstream) - extracted_data = gzipper.read() - dat = extracted_data - - # Write it to a file - file.write(dat.strip()) - file.close() - # return file path - print path+" "+url - - class SimpleSGMLParser(sgmllib.SGMLParser): - def __init__(self, results, url, what, *args): - sgmllib.SGMLParser.__init__(self) - self.url = url - self.li_counter = None - self.current_item = None - self.results = results - self.what = what.upper().split('+') - if len(self.what) == 0: - self.what = None - - def start_a(self, attr): - params = dict(attr) - #print params - if params.has_key('href') and params['href'].startswith("http://www.torrentdownloads.net/torrent/"): - self.current_item = {} - self.li_counter = 0 - self.current_item['desc_link'] = params['href'].strip() - self.current_item['link']=params['href'].strip().replace('/torrent', '/download', 1) - - def handle_data(self, data): - if self.li_counter == 0: - if not self.current_item.has_key('name'): - self.current_item['name'] = '' - self.current_item['name']+= data - elif self.li_counter == 1: - if not self.current_item.has_key('size'): - self.current_item['size'] = '' - self.current_item['size']+= data.strip().replace(" ", " ") - elif self.li_counter == 2: - if not self.current_item.has_key('seeds'): - self.current_item['seeds'] = '' - self.current_item['seeds']+= data.strip() - elif self.li_counter == 3: - if not self.current_item.has_key('leech'): - self.current_item['leech'] = '' - self.current_item['leech']+= data.strip() - - def start_li(self,attr): - if isinstance(self.li_counter,int): - self.li_counter += 1 - if self.li_counter > 3: - self.li_counter = None - # Display item - if self.current_item: - self.current_item['engine_url'] = self.url - if not self.current_item['seeds'].isdigit(): - self.current_item['seeds'] = 0 - if not self.current_item['leech'].isdigit(): - self.current_item['leech'] = 0 - # Search should use AND operator as a default - tmp = self.current_item['name'].upper(); - if self.what is not None: - for w in self.what: - if tmp.find(w) < 0: return - prettyPrinter(self.current_item) - self.results.append('a') - - def search(self, what, cat='all'): - ret = [] - i = 1 - while i<11: - results = [] - parser = self.SimpleSGMLParser(results, self.url, what) - dat = retrieve_url(self.url+'/search/?page=%d&search=%s&s_cat=%s&srt=seeds&pp=50&order=desc'%(i, what, self.supported_categories[cat])) - results_re = re.compile('(?s)
.*') - for match in results_re.finditer(dat): - res_tab = match.group(0) - parser.feed(res_tab) - parser.close() - break - if len(results) <= 0: - break - i += 1 - diff --git a/src/searchengine/nova3/engines/torrentdownloads.png b/src/searchengine/nova3/engines/torrentdownloads.png deleted file mode 100644 index ce14cea487d289ace537cb4139b8f5080e39ee47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 423 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgga9zJ1R#dR;W-U3Zg_jGX#u{gbS zvcDIzp~TVosbcdEuVw$hbdL428MU*)fpNNzF=Wk_0z3E{OFv^)dlAm8J^`- z)K&OAE92wWdh2>oSx_X$v;5pa%l0N-7daQX+tt4nK2_}6yShe2NchP@OGmjiq0>2y z^qXulm=qSZ24;5$$ug!kEwxT~mht4)I`3W6625Z$-Mm`sRsO7y@P-9lO}FclXQq`I zvN7cJ>S@;pxE|Z}tLN*s%9?pSujBd{vj1w-Uu%k5bFBaS_H(RXnO{}0yj{NJwJ|Uh O89ZJ6T-G@yGywp^OsDMt diff --git a/src/searchengine/nova3/engines/torrentdownloads.py b/src/searchengine/nova3/engines/torrentdownloads.py deleted file mode 100644 index 6bb3e2b4b..000000000 --- a/src/searchengine/nova3/engines/torrentdownloads.py +++ /dev/null @@ -1,141 +0,0 @@ -#VERSION: 1.1 -#AUTHORS: Christophe Dumez (chris@qbittorrent.org) - -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the author nor the names of its contributors may be -# used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - - -from novaprinter import prettyPrinter -from helpers import retrieve_url -import io, gzip, urllib.request, urllib.error, urllib.parse, tempfile -import sgmllib3 -import re -import os - -class torrentdownloads(object): - url = 'http://www.torrentdownloads.net' - name = 'TorrentDownloads' - supported_categories = {'all': '0', 'movies': '4', 'tv': '8', 'music': '5', 'games': '3', 'anime': '1', 'software': '7', 'books': '2'} - - def __init__(self): - self.results = [] - #self.parser = self.SimpleSGMLParser(self.results, self.url) - - def download_torrent(self, url): - """ Download file at url and write it to a file, return the path to the file and the url """ - file, path = tempfile.mkstemp() - file = os.fdopen(file, "w") - # Download url - req = urllib.request.Request(url) - response = urllib.request.urlopen(req) - dat = response.read() - # Check if it is gzipped - if dat[:2] == '\037\213': - # Data is gzip encoded, decode it - compressedstream = io.StringIO(dat) - gzipper = gzip.GzipFile(fileobj=compressedstream) - extracted_data = gzipper.read() - dat = extracted_data - - # Write it to a file - file.write(dat.strip()) - file.close() - # return file path - print(path+" "+url) - - class SimpleSGMLParser(sgmllib3.SGMLParser): - def __init__(self, results, url, what, *args): - sgmllib3.SGMLParser.__init__(self) - self.url = url - self.li_counter = None - self.current_item = None - self.results = results - self.what = what.upper().split('+') - if len(self.what) == 0: - self.what = None - - def start_a(self, attr): - params = dict(attr) - #print params - if 'href' in params and params['href'].startswith("http://www.torrentdownloads.net/torrent/"): - self.current_item = {} - self.li_counter = 0 - self.current_item['desc_link'] = params['href'].strip() - self.current_item['link']=params['href'].strip().replace('/torrent', '/download', 1) - - def handle_data(self, data): - if self.li_counter == 0: - if 'name' not in self.current_item: - self.current_item['name'] = '' - self.current_item['name']+= data - elif self.li_counter == 1: - if 'size' not in self.current_item: - self.current_item['size'] = '' - self.current_item['size']+= data.strip().replace(" ", " ") - elif self.li_counter == 2: - if 'seeds' not in self.current_item: - self.current_item['seeds'] = '' - self.current_item['seeds']+= data.strip() - elif self.li_counter == 3: - if 'leech' not in self.current_item: - self.current_item['leech'] = '' - self.current_item['leech']+= data.strip() - - def start_li(self,attr): - if isinstance(self.li_counter,int): - self.li_counter += 1 - if self.li_counter > 3: - self.li_counter = None - # Display item - if self.current_item: - self.current_item['engine_url'] = self.url - if not self.current_item['seeds'].isdigit(): - self.current_item['seeds'] = 0 - if not self.current_item['leech'].isdigit(): - self.current_item['leech'] = 0 - # Search should use AND operator as a default - tmp = self.current_item['name'].upper(); - if self.what is not None: - for w in self.what: - if tmp.find(w) < 0: return - prettyPrinter(self.current_item) - self.results.append('a') - - def search(self, what, cat='all'): - ret = [] - i = 1 - while i<11: - results = [] - parser = self.SimpleSGMLParser(results, self.url, what) - dat = retrieve_url(self.url+'/search/?page=%d&search=%s&s_cat=%s&srt=seeds&pp=50&order=desc'%(i, what, self.supported_categories[cat])) - results_re = re.compile('(?s)
.*') - for match in results_re.finditer(dat): - res_tab = match.group(0) - parser.feed(res_tab) - parser.close() - break - if len(results) <= 0: - break - i += 1 - diff --git a/src/searchengine/search.qrc b/src/searchengine/search.qrc index 015a0d34c..4a78aa158 100644 --- a/src/searchengine/search.qrc +++ b/src/searchengine/search.qrc @@ -18,8 +18,6 @@ nova/engines/mininova.py nova/engines/piratebay.png nova/engines/piratebay.py - nova/engines/torrentdownloads.png - nova/engines/torrentdownloads.py nova/engines/torrentreactor.png nova/engines/torrentreactor.py nova/engines/vertor.png @@ -42,8 +40,6 @@ nova3/engines/mininova.py nova3/engines/piratebay.png nova3/engines/piratebay.py - nova3/engines/torrentdownloads.png - nova3/engines/torrentdownloads.py nova3/engines/torrentreactor.png nova3/engines/torrentreactor.py nova3/engines/vertor.png