Browse Source

- Fix piratebay search plugin

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
97c0b28a98
  1. 30
      src/search_engine/engines/piratebay.py
  2. 2
      src/search_engine/engines/versions.txt

30
src/search_engine/engines/piratebay.py

@ -1,4 +1,4 @@
#VERSION: 1.22 #VERSION: 1.30
#AUTHORS: Fabien Devaux (fab@gnux.info) #AUTHORS: Fabien Devaux (fab@gnux.info)
#CONTRIBUTORS: Christophe Dumez (chris@qbittorrent.org) #CONTRIBUTORS: Christophe Dumez (chris@qbittorrent.org)
@ -50,32 +50,35 @@ class piratebay(object):
self.results = results self.results = results
self.url = url self.url = url
self.code = 0 self.code = 0
self.in_name = None
def start_a(self, attr): def start_a(self, attr):
params = dict(attr) params = dict(attr)
if params['href'].startswith('/browse'): if params['href'].startswith('/torrent/'):
self.current_item = {} self.current_item = {}
self.td_counter = 0 self.td_counter = 0
elif params['href'].startswith('/tor'):
self.code = params['href'].split('/')[2] self.code = params['href'].split('/')[2]
self.in_name = True
elif params['href'].startswith('http://torrents.thepiratebay.org/%s'%self.code): elif params['href'].startswith('http://torrents.thepiratebay.org/%s'%self.code):
self.current_item['link']=params['href'].strip() self.current_item['link']=params['href'].strip()
self.td_counter = self.td_counter+1 self.in_name = False
def handle_data(self, data): def handle_data(self, data):
if self.td_counter == 1: if self.td_counter == 0:
if self.in_name:
if not self.current_item.has_key('name'): if not self.current_item.has_key('name'):
self.current_item['name'] = '' self.current_item['name'] = ''
self.current_item['name']+= data.strip() self.current_item['name']+= data.strip()
if self.td_counter == 5: else:
if not self.current_item.has_key('size'): #Parse size
self.current_item['size'] = '' if 'Size' in data:
self.current_item['size']+= data.strip() self.current_item['size'] = data[data.index("Size")+5:]
elif self.td_counter == 6: self.current_item['size'] = self.current_item['size'][:self.current_item['size'].index(',')]
elif self.td_counter == 1:
if not self.current_item.has_key('seeds'): if not self.current_item.has_key('seeds'):
self.current_item['seeds'] = '' self.current_item['seeds'] = ''
self.current_item['seeds']+= data.strip() self.current_item['seeds']+= data.strip()
elif self.td_counter == 7: elif self.td_counter == 2:
if not self.current_item.has_key('leech'): if not self.current_item.has_key('leech'):
self.current_item['leech'] = '' self.current_item['leech'] = ''
self.current_item['leech']+= data.strip() self.current_item['leech']+= data.strip()
@ -83,7 +86,7 @@ class piratebay(object):
def start_td(self,attr): def start_td(self,attr):
if isinstance(self.td_counter,int): if isinstance(self.td_counter,int):
self.td_counter += 1 self.td_counter += 1
if self.td_counter > 7: if self.td_counter > 3:
self.td_counter = None self.td_counter = None
# Display item # Display item
if self.current_item: if self.current_item:
@ -101,7 +104,8 @@ class piratebay(object):
while True and i<11: while True and i<11:
results = [] results = []
parser = self.SimpleSGMLParser(results, self.url) parser = self.SimpleSGMLParser(results, self.url)
dat = retrieve_url(self.url+'/search/%s/%u/99/%s' % (what, i, self.supported_categories[cat])) dat = retrieve_url(self.url+'/search/%s/%u/7/%s' % (what, i, self.supported_categories[cat]))
print self.url+'/search/%s/%u/7/%s' % (what, i, self.supported_categories[cat])
parser.feed(dat) parser.feed(dat)
parser.close() parser.close()
if len(results) <= 0: if len(results) <= 0:

2
src/search_engine/engines/versions.txt

@ -2,4 +2,4 @@ isohunt: 1.30
torrentreactor: 1.20 torrentreactor: 1.20
btjunkie: 2.21 btjunkie: 2.21
mininova: 1.32 mininova: 1.32
piratebay: 1.22 piratebay: 1.30

Loading…
Cancel
Save