From e3f2480fe5cedc2cfaeb612e94c787e1d64e6e94 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 31 Aug 2007 16:15:39 +0000 Subject: [PATCH] - Added multipage support to btjunkie plugin --- src/search_engine/engines/btjunkie.py | 44 +++++++++++++++----------- src/search_engine/engines/versions.txt | 2 +- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/search_engine/engines/btjunkie.py b/src/search_engine/engines/btjunkie.py index 25dbfff0d..67e2da817 100644 --- a/src/search_engine/engines/btjunkie.py +++ b/src/search_engine/engines/btjunkie.py @@ -1,29 +1,35 @@ -#VERSION: 1.01 +#VERSION: 1.10 #AUTHORS: Fabien Devaux (fab@gnux.info) from novaprinter import prettyPrinter import urllib import re -# TODO: add multipage class btjunkie(object): url = 'http://btjunkie.org' name = 'btjunkie' def search(self, what): - dat = urllib.urlopen(self.url+'/search?q=%s&o=52'%what).read().decode('utf8', 'replace') - # I know it's not very readable, but the SGML parser feels in pain - section_re = re.compile('(?s)href="/torrent.*?') - torrent_re = re.compile('(?s)href="(?P.*?[^"]+).*?' - 'class="BlckUnd">(?P.*?).*?' - '>(?P\d+MB).*?' - '>(?P\d+).*?' - '>(?P\d+)') - for match in section_re.finditer(dat): - txt = match.group(0) - m = torrent_re.search(txt) - if m: - torrent_infos = m.groupdict() - torrent_infos['name'] = re.sub('', '', torrent_infos['name']) - torrent_infos['engine_url'] = self.url - torrent_infos['link'] = self.url+torrent_infos['link'] - prettyPrinter(torrent_infos) \ No newline at end of file + i = 1 + while True: + res = 0 + dat = urllib.urlopen(self.url+'/search?q=%s&o=52&p=%d'%(what,i)).read().decode('utf8', 'replace') + # I know it's not very readable, but the SGML parser feels in pain + section_re = re.compile('(?s)href="/torrent.*?') + torrent_re = re.compile('(?s)href="(?P.*?[^"]+).*?' + 'class="BlckUnd">(?P.*?).*?' + '>(?P\d+MB).*?' + '>(?P\d+).*?' + '>(?P\d+)') + for match in section_re.finditer(dat): + txt = match.group(0) + m = torrent_re.search(txt) + if m: + torrent_infos = m.groupdict() + torrent_infos['name'] = re.sub('', '', 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 \ No newline at end of file diff --git a/src/search_engine/engines/versions.txt b/src/search_engine/engines/versions.txt index 81b5db4ab..68dd72599 100644 --- a/src/search_engine/engines/versions.txt +++ b/src/search_engine/engines/versions.txt @@ -1,5 +1,5 @@ isohunt: 1.00 torrentreactor: 1.00 -btjunkie: 1.01 +btjunkie: 1.10 mininova: 1.00 piratebay: 1.00 \ No newline at end of file