Browse Source

FEATURE: Replaced Meganova search engine by TorrentReactor

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
4a2c7efb27
  1. 3
      TODO
  2. 2
      src/search.ui
  3. 14
      src/searchEngine.cpp
  4. 25
      src/search_engine/nova.py

3
TODO

@ -50,7 +50,7 @@
- valgrind --tool=memcheck --leak-check=full src/qbittorrent (Looks ok) - valgrind --tool=memcheck --leak-check=full src/qbittorrent (Looks ok)
- 128m 29m 16m S 4.8 2.9 0:02.28 qbittorrent - 128m 29m 16m S 4.8 2.9 0:02.28 qbittorrent
* beta 6 * beta 6
- Fix Qt4.2 compatibility (download.ui) - Fix Qt4.2 compatibility (toolbar)
- Fix meganova search engine - Fix meganova search engine
- Translations update (IN PROGRESS) - Translations update (IN PROGRESS)
- Wait for some bug fixes in libtorrent : - Wait for some bug fixes in libtorrent :
@ -79,6 +79,7 @@ beta5->beta6 changelog:
- FEATURE: Split download tab from GUI class and cleaned up code - FEATURE: Split download tab from GUI class and cleaned up code
- FEATURE: A lot of code optimization (CPU & memory usage) - FEATURE: A lot of code optimization (CPU & memory usage)
- FEATURE: Added support for .ico format (useful for RSS favicons) - FEATURE: Added support for .ico format (useful for RSS favicons)
- FEATURE: Replaced Meganova search engine by TorrentReactor
- I18N: Updated Greek translation - I18N: Updated Greek translation
- BUGFIX: Made torrent deletion from hard-drive safer - BUGFIX: Made torrent deletion from hard-drive safer
- BUGFIX: Fixed a bug when switching from finished to downloading list - BUGFIX: Fixed a bug when switching from finished to downloading list

2
src/search.ui

@ -76,7 +76,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="meganova" > <widget class="QCheckBox" name="reactor" >
<property name="text" > <property name="text" >
<string/> <string/>
</property> </property>

14
src/searchEngine.cpp

@ -87,7 +87,7 @@ SearchEngine::SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, b
// reactor->setText("TorrentReactor"); // reactor->setText("TorrentReactor");
isohunt->setText("Isohunt"); isohunt->setText("Isohunt");
// btjunkie->setText("BTJunkie"); // btjunkie->setText("BTJunkie");
meganova->setText("Meganova"); reactor->setText("TorrentReactor");
// Check last checked search engines // Check last checked search engines
loadCheckedSearchEngines(); loadCheckedSearchEngines();
connect(mininova, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int))); connect(mininova, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
@ -95,7 +95,7 @@ SearchEngine::SearchEngine(bittorrent *BTSession, QSystemTrayIcon *myTrayIcon, b
// connect(reactor, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int))); // connect(reactor, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
connect(isohunt, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int))); connect(isohunt, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
// connect(btjunkie, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int))); // connect(btjunkie, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
connect(meganova, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int))); connect(reactor, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
// Update nova.py search plugin if necessary // Update nova.py search plugin if necessary
updateNova(); updateNova();
} }
@ -190,7 +190,7 @@ void SearchEngine::saveCheckedSearchEngines(int) const{
settings.setValue("mininova", mininova->isChecked()); settings.setValue("mininova", mininova->isChecked());
settings.setValue("piratebay", piratebay->isChecked()); settings.setValue("piratebay", piratebay->isChecked());
settings.setValue("isohunt", isohunt->isChecked()); settings.setValue("isohunt", isohunt->isChecked());
settings.setValue("meganova", meganova->isChecked()); settings.setValue("reactor", reactor->isChecked());
settings.endGroup(); settings.endGroup();
qDebug("Saved checked search engines"); qDebug("Saved checked search engines");
} }
@ -234,7 +234,7 @@ void SearchEngine::loadCheckedSearchEngines(){
mininova->setChecked(settings.value("mininova", true).toBool()); mininova->setChecked(settings.value("mininova", true).toBool());
piratebay->setChecked(settings.value("piratebay", false).toBool()); piratebay->setChecked(settings.value("piratebay", false).toBool());
isohunt->setChecked(settings.value("isohunt", false).toBool()); isohunt->setChecked(settings.value("isohunt", false).toBool());
meganova->setChecked(settings.value("meganova", false).toBool()); reactor->setChecked(settings.value("reactor", false).toBool());
settings.endGroup(); settings.endGroup();
qDebug("Loaded checked search engines"); qDebug("Loaded checked search engines");
} }
@ -282,7 +282,7 @@ void SearchEngine::on_search_button_clicked(){
// Getting checked search engines // Getting checked search engines
if(!mininova->isChecked() && ! piratebay->isChecked()/* && !reactor->isChecked()*/ && !isohunt->isChecked()/* && !btjunkie->isChecked()*/ && !meganova->isChecked()){ if(!mininova->isChecked() && ! piratebay->isChecked() && !reactor->isChecked() && !isohunt->isChecked()/* && !btjunkie->isChecked()*/ /*&& !meganova->isChecked()*/){
QMessageBox::critical(0, tr("No search engine selected"), tr("You must select at least one search engine.")); QMessageBox::critical(0, tr("No search engine selected"), tr("You must select at least one search engine."));
return; return;
} }
@ -305,8 +305,8 @@ void SearchEngine::on_search_button_clicked(){
// if(btjunkie->isChecked()){ // if(btjunkie->isChecked()){
// engineNames << "btjunkie"; // engineNames << "btjunkie";
// } // }
if(meganova->isChecked()){ if(reactor->isChecked()){
engineNames << "meganova"; engineNames << "reactor";
} }
params << engineNames.join(","); params << engineNames.join(",");
params << pattern.split(" "); params << pattern.split(" ");

25
src/search_engine/nova.py

@ -1,5 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Version: 2.04
# Changelog:
# - Fixed TorrentReactor search engine
# Version: 2.03 # Version: 2.03
# Changelog: # Changelog:
# - Little fix for mininova search engine when file name contain '<=' # - Little fix for mininova search engine when file name contain '<='
@ -55,7 +59,7 @@ import cgi
import traceback import traceback
import threading import threading
STANDALONE = True STANDALONE = False
THREADED = True THREADED = True
if os.environ.has_key('QBITTORRENT'): if os.environ.has_key('QBITTORRENT'):
@ -274,11 +278,11 @@ class MegaNova(object):
url = 'http://www.meganova.org' url = 'http://www.meganova.org'
def search(self, what): def search(self, what):
dat = urllib.urlopen(self.url+'/find-seeds/%s.html'%what).read().decode('utf8', 'replace') dat = urllib.urlopen(self.url+'/find/%s/4/1.html'%what).read().decode('utf8', 'replace')
print 'url is ' + self.url+'/find-seeds/%s.html'%what print 'url is ' + self.url+'/find/%s/4/1.html'%what
# I know it's not very readable, but the SGML parser feels in pain # I know it's not very readable, but the SGML parser feels in pain
section_re = re.compile('(?s)<td width="6%">.*?</tr') section_re = re.compile('(?s)<td><a class="name".*?</tr')
torrent_re = re.compile('(?s)href="(?P<link>/torrent/.*?)".*?' torrent_re = re.compile('(?s)href="(?P<link>/torrent/.*?)".*?'
'<span.*?>(?P<name>.*?)</span>.*?' '<span.*?>(?P<name>.*?)</span>.*?'
'>(?P<size>[0-9.]+\s+.B).*?' '>(?P<size>[0-9.]+\s+.B).*?'
@ -296,7 +300,7 @@ class MegaNova(object):
prettyPrinter(torrent_infos) prettyPrinter(torrent_infos)
class Reactor(object): class Reactor(object):
url = 'http://tr.searching.com' url = 'http://www.torrentreactor.net'
class SimpleSGMLParser(sgmllib.SGMLParser): class SimpleSGMLParser(sgmllib.SGMLParser):
def __init__(self, results, url, *args): def __init__(self, results, url, *args):
@ -309,13 +313,12 @@ class Reactor(object):
def start_a(self, attr): def start_a(self, attr):
params = dict(attr) params = dict(attr)
if params['href'].startswith('view.php'): if params['href'].startswith('http://dl.torrentreactor.net/download.php'):
self.current_item = {} self.current_item = {}
self.td_counter = 0 self.td_counter = 0
# extract the torrent id
#I save it in a global variable for after create the link string
equal = params['href'].find("=") equal = params['href'].find("=")
self.id = str(int(params['href'][equal+1:])) amp = params['href'].find("&", equal+1)
self.id = str(int(params['href'][equal+1:amp]))
def handle_data(self, data): def handle_data(self, data):
if self.td_counter == 0: if self.td_counter == 0:
@ -342,7 +345,7 @@ class Reactor(object):
self.td_counter = None self.td_counter = None
# add item to results # add item to results
if self.current_item: if self.current_item:
self.current_item['link']='http://download.torrentreactor.net/download.php?name=%s&id=%s'%(cgi.escape(self.current_item['name']),self.id) self.current_item['link']='http://download.torrentreactor.net/download.php?id=%s&name=%s'%(self.id, urllib.quote(self.current_item['name']))
self.current_item['engine_url'] = self.url self.current_item['engine_url'] = self.url
self.current_item['size']= anySizeToBytes(self.current_item['size']) self.current_item['size']= anySizeToBytes(self.current_item['size'])
if not self.current_item['seeds'].isdigit(): if not self.current_item['seeds'].isdigit():
@ -362,7 +365,7 @@ class Reactor(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?search=&words=%s&skip=%s'%(what,(i*50))).read().decode('utf-8', 'replace') dat = urllib.urlopen(self.url+'/search.php?search=&words=%s&cid=&sid=&type=2&orderby=a.seeds&asc=0&skip=%s'%(what,(i*35))).read().decode('utf-8', 'replace')
parser.feed(dat) parser.feed(dat)
parser.close() parser.close()
if len(results) <= 0: if len(results) <= 0:

Loading…
Cancel
Save