Browse Source

- Fixed ThePirateBay search engine

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
9b91bac228
  1. 10
      src/search_engine/nova.py

10
src/search_engine/nova.py

@ -1,5 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Version: 2.0
# - Fixed ThePirateBay search engine
# Version: 1.9 # Version: 1.9
# Changelog: # Changelog:
# - Various fixes # - Various fixes
@ -131,13 +134,16 @@ class PirateBay(object):
self.current_item = None self.current_item = None
self.results = results self.results = results
self.url = url self.url = url
self.code = 0
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('/browse'):
self.current_item = {} self.current_item = {}
self.td_counter = 0 self.td_counter = 0
elif params['href'].startswith('http://torrents.thepiratebay.org/hashtorrent'): elif params['href'].startswith('/tor'):
self.code = params['href'].split('/')[2]
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.td_counter = self.td_counter+1
@ -181,7 +187,7 @@ class PirateBay(object):
while True: while True:
results = [] results = []
parser = self.SimpleSGMLParser(results, self.url) parser = self.SimpleSGMLParser(results, self.url)
dat = urllib.urlopen(self.url+'/search.php?q=%s&orderby=%s&what=search&page=%u' % (what, order, i)).read() dat = urllib.urlopen(self.url+'/search/%s/%u/0/0' % (what, i)).read()
parser.feed(dat) parser.feed(dat)
parser.close() parser.close()
if len(results) <= 0: if len(results) <= 0:

Loading…
Cancel
Save