- Added multipage support to btjunkie plugin

This commit is contained in:
Christophe Dumez 2007-08-31 16:15:39 +00:00
parent 26e5785754
commit e3f2480fe5
2 changed files with 26 additions and 20 deletions

View file

@ -1,29 +1,35 @@
#VERSION: 1.01 #VERSION: 1.10
#AUTHORS: Fabien Devaux (fab@gnux.info) #AUTHORS: Fabien Devaux (fab@gnux.info)
from novaprinter import prettyPrinter from novaprinter import prettyPrinter
import urllib import urllib
import re import re
# TODO: add multipage
class btjunkie(object): class btjunkie(object):
url = 'http://btjunkie.org' url = 'http://btjunkie.org'
name = 'btjunkie' name = 'btjunkie'
def search(self, what): def search(self, what):
dat = urllib.urlopen(self.url+'/search?q=%s&o=52'%what).read().decode('utf8', 'replace') i = 1
# I know it's not very readable, but the SGML parser feels in pain while True:
section_re = re.compile('(?s)href="/torrent.*?<tr>') res = 0
torrent_re = re.compile('(?s)href="(?P<link>.*?[^"]+).*?' dat = urllib.urlopen(self.url+'/search?q=%s&o=52&p=%d'%(what,i)).read().decode('utf8', 'replace')
'class="BlckUnd">(?P<name>.*?)</a>.*?' # I know it's not very readable, but the SGML parser feels in pain
'>(?P<size>\d+MB)</font>.*?' section_re = re.compile('(?s)href="/torrent.*?<tr>')
'>(?P<seeds>\d+)</font>.*?' torrent_re = re.compile('(?s)href="(?P<link>.*?[^"]+).*?'
'>(?P<leech>\d+)</font>') 'class="BlckUnd">(?P<name>.*?)</a>.*?'
for match in section_re.finditer(dat): '>(?P<size>\d+MB)</font>.*?'
txt = match.group(0) '>(?P<seeds>\d+)</font>.*?'
m = torrent_re.search(txt) '>(?P<leech>\d+)</font>')
if m: for match in section_re.finditer(dat):
torrent_infos = m.groupdict() txt = match.group(0)
torrent_infos['name'] = re.sub('</?font.*?>', '', torrent_infos['name']) m = torrent_re.search(txt)
torrent_infos['engine_url'] = self.url if m:
torrent_infos['link'] = self.url+torrent_infos['link'] torrent_infos = m.groupdict()
prettyPrinter(torrent_infos) torrent_infos['name'] = re.sub('</?font.*?>', '', torrent_infos['name'])
torrent_infos['engine_url'] = self.url
torrent_infos['link'] = self.url+torrent_infos['link']
prettyPrinter(torrent_infos)
res = res + 1
if res == 0:
break
i = i + 1

View file

@ -1,5 +1,5 @@
isohunt: 1.00 isohunt: 1.00
torrentreactor: 1.00 torrentreactor: 1.00
btjunkie: 1.01 btjunkie: 1.10
mininova: 1.00 mininova: 1.00
piratebay: 1.00 piratebay: 1.00