From 511c4474c7d7b26a51f64fb9815b932e64dab0bc Mon Sep 17 00:00:00 2001
From: Christophe Dumez <chris@qbittorrent.org>
Date: Thu, 7 Jan 2010 21:08:58 +0000
Subject: [PATCH] - Promoted torrentdownloads.net and vertor.com search plugins
 from unofficial plugins to official (in qBittorrent v2.1.0)

---
 .../engines/torrentdownloads.png              | Bin 0 -> 423 bytes
 src/search_engine/engines/torrentdownloads.py | 111 ++++++++++++++++++
 src/search_engine/engines/versions.txt        |   2 +
 src/search_engine/engines/vertor.png          | Bin 0 -> 643 bytes
 src/search_engine/engines/vertor.py           | 111 ++++++++++++++++++
 5 files changed, 224 insertions(+)
 create mode 100644 src/search_engine/engines/torrentdownloads.png
 create mode 100644 src/search_engine/engines/torrentdownloads.py
 create mode 100644 src/search_engine/engines/vertor.png
 create mode 100755 src/search_engine/engines/vertor.py

diff --git a/src/search_engine/engines/torrentdownloads.png b/src/search_engine/engines/torrentdownloads.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce14cea487d289ace537cb4139b8f5080e39ee47
GIT binary patch
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$hbd<Y-!8O23@QUm1!qptRHYkZ)TpOJq@Ig)QNbBpFv-E%d
zThU!|%+tErfQ?E2$<yi6?eE|E(YpU*|FllYU(&DVik*+Mt;)GpS#IVm79#j&wXnhp
zCGJHEy$vtVZn<b-BWuQ-!uVqf#|>L428MU*)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

literal 0
HcmV?d00001

diff --git a/src/search_engine/engines/torrentdownloads.py b/src/search_engine/engines/torrentdownloads.py
new file mode 100644
index 000000000..bbfb4de42
--- /dev/null
+++ b/src/search_engine/engines/torrentdownloads.py
@@ -0,0 +1,111 @@
+#VERSION: 1.01
+#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, download_file
+import sgmllib
+import re
+
+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, info):
+    print download_file(info)
+
+  class SimpleSGMLParser(sgmllib.SGMLParser):
+    def __init__(self, results, url, *args):
+      sgmllib.SGMLParser.__init__(self)
+      self.url = url
+      self.li_counter = None
+      self.current_item = None
+      self.results = results
+      
+    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['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("&nbsp;", " ")
+      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
+              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)
+      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)<div class="torrentlist">.*')
+      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
+      
\ No newline at end of file
diff --git a/src/search_engine/engines/versions.txt b/src/search_engine/engines/versions.txt
index 9ff5f6d07..67457256c 100644
--- a/src/search_engine/engines/versions.txt
+++ b/src/search_engine/engines/versions.txt
@@ -3,3 +3,5 @@ torrentreactor: 1.20
 btjunkie: 2.21
 mininova: 1.40
 piratebay: 1.30
+vertor: 1.0
+torrentdownloads: 1.01
diff --git a/src/search_engine/engines/vertor.png b/src/search_engine/engines/vertor.png
new file mode 100644
index 0000000000000000000000000000000000000000..f9975f508bb42ca0e328fe3175c20491c43e998c
GIT binary patch
literal 643
zcmV-}0(||6P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00001b5ch_0Itp)
z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXf7
z6Brt3G<w1S00IL^L_t(I%YD<$ZW2)##_|6QOhG7Lg*K@rQ3y%}O)WO5sWB;QjT>XU
z0I$HC@ETmZaN)|tt*sxix{-oJt3_yvEm#K2R2V*_z__3p90#4%n=|kE<(zk(5gu(l
z(2~JB1YHpTN@{`iy(f%&!tOZN=57J-qy3%d-yUN<>Qvb%KjUunJ^=M@ji>pCV}YCD
zdphv(@GaF=2@zmZexWyo+%e{-mQ0(iqQuJV4FEJWveh>LL!hJ<C^vTiuv?u(ybC74
zYnvwQy##>Lk@<R*83FB{N=AOIH^=?U2!dz;E(TVR#0dcQ8ac}9&Ikbbboh>e)(0Tw
zUuIJB7=SA?NxjZgU+J|D<digWYaf6~$!nN{Yr;p!69=F_=<)tw%?#8!6^e~7`iq6Y
z_0eEGaRR4K1F&1);-FPD0|06HrCy((N+1dr0HVGGl4t`UC9msOH36y08o&B&0A?L$
z3Atkk2*mwY0XQCX$yPTEvoQclM<%Ci0^pEbobg=1Zgp_Zdl`UzHBU*+{~OTINL5Cm
zn)fZSIFrO~bplX0%2Myvi~;*QFgYbfr`N=8brSU@@YwuATpN)7Be7#o08ngfvs?cR
zz?>_>;`Ay2Kf5(PoW%FPK&RK#V=5qE5r>D|R#LQks`(!QSPkAbEVhqT`dS~$$!7$p
dwo9fyfZx~Nxu{`V$ZP-r002ovPDHLkV1gdb5O@Fp

literal 0
HcmV?d00001

diff --git a/src/search_engine/engines/vertor.py b/src/search_engine/engines/vertor.py
new file mode 100755
index 000000000..41086e770
--- /dev/null
+++ b/src/search_engine/engines/vertor.py
@@ -0,0 +1,111 @@
+#VERSION: 1.0
+#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, download_file
+import sgmllib
+import re
+
+class vertor(object):
+  url = 'http://www.vertor.com'
+  name = 'vertor'
+  supported_categories = {'all': '0', 'movies': '5', 'tv': '8', 'music': '6', 'games': '3', 'anime': '1', 'software': '2'}
+
+  def __init__(self):
+    self.results = []
+    self.parser = self.SimpleSGMLParser(self.results, self.url)
+
+  def download_torrent(self, info):
+    print download_file(info)
+
+  class SimpleSGMLParser(sgmllib.SGMLParser):
+    def __init__(self, results, url, *args):
+      sgmllib.SGMLParser.__init__(self)
+      self.url = url
+      self.td_counter = None
+      self.current_item = None
+      self.results = results
+      
+    def start_a(self, attr):
+      params = dict(attr)
+      #print params
+      if params.has_key('href') and params['href'].startswith("http://www.vertor.com/index.php?mod=download"):
+        self.current_item = {}
+        self.td_counter = 0
+        self.current_item['link']=params['href'].strip()
+    
+    def handle_data(self, data):
+      if self.td_counter == 0:
+        if not self.current_item.has_key('name'):
+          self.current_item['name'] = ''
+        self.current_item['name']+= data.strip()
+      elif self.td_counter == 3:
+        if not self.current_item.has_key('size'):
+          self.current_item['size'] = ''
+        self.current_item['size']+= data.strip()
+      elif self.td_counter == 4:
+        if not self.current_item.has_key('seeds'):
+          self.current_item['seeds'] = ''
+        self.current_item['seeds']+= data.strip()
+      elif self.td_counter == 5:
+        if not self.current_item.has_key('leech'):
+          self.current_item['leech'] = ''
+        self.current_item['leech']+= data.strip()
+      
+    def start_td(self,attr):
+        if isinstance(self.td_counter,int):
+          self.td_counter += 1
+          if self.td_counter > 6:
+            self.td_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
+              prettyPrinter(self.current_item)
+              self.results.append('a')
+
+  def search(self, what, cat='all'):
+    ret = []
+    i = 0
+    while True and i<11:
+      results = []
+      parser = self.SimpleSGMLParser(results, self.url)
+      dat = retrieve_url(self.url+'/index.php?mod=search&words=%s&cid=%s&orderby=a.seeds&asc=0&search=&exclude=&p=%d'%(what, self.supported_categories[cat], i))
+      results_re = re.compile('(?s)Vertor search results.*')
+      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
+      
\ No newline at end of file