mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-09 14:27:56 +00:00
- Fixed plugin update && fixed btjunkie search plugin
This commit is contained in:
parent
db12fb292a
commit
26e5785754
@ -331,6 +331,7 @@ class misc : public QObject{
|
|||||||
static float getPluginVersion(QString filePath) {
|
static float getPluginVersion(QString filePath) {
|
||||||
QFile plugin(filePath);
|
QFile plugin(filePath);
|
||||||
if(!plugin.exists()){
|
if(!plugin.exists()){
|
||||||
|
qDebug("%s plugin does not exist, returning 0.0", filePath.toUtf8().data());
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if(!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if(!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||||
@ -343,7 +344,7 @@ class misc : public QObject{
|
|||||||
line = line.split(' ').last();
|
line = line.split(' ').last();
|
||||||
line.replace("\n", "");
|
line.replace("\n", "");
|
||||||
version = line.toFloat();
|
version = line.toFloat();
|
||||||
qDebug("plugin version: %.2f", version);
|
qDebug("plugin %s version: %.2f", filePath.toUtf8().data(), version);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,76 +352,34 @@ void SearchEngine::updateNova() {
|
|||||||
if(!QFile::exists(misc::qBittorrentPath()+"search_engine"+QDir::separator()+"novaprinter.py")){
|
if(!QFile::exists(misc::qBittorrentPath()+"search_engine"+QDir::separator()+"novaprinter.py")){
|
||||||
QFile::copy(":/search_engine/novaprinter.py", misc::qBittorrentPath()+"search_engine"+QDir::separator()+"novaprinter.py");
|
QFile::copy(":/search_engine/novaprinter.py", misc::qBittorrentPath()+"search_engine"+QDir::separator()+"novaprinter.py");
|
||||||
}
|
}
|
||||||
QString subDir = misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator();
|
QString destDir = misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator();
|
||||||
QDir search_subDir(":/search_engine/engines");
|
QDir shipped_subDir(":/search_engine/engines/");
|
||||||
QStringList files = search_subDir.entryList();
|
QStringList files = shipped_subDir.entryList();
|
||||||
QString file;
|
QString file;
|
||||||
foreach(file, files){
|
foreach(file, files){
|
||||||
filePath = search_subDir.path()+QDir::separator()+file;
|
QString shipped_file = shipped_subDir.path()+QDir::separator()+file;
|
||||||
// Copy python classes
|
// Copy python classes
|
||||||
if(file.endsWith(".py")) {
|
if(file.endsWith(".py")) {
|
||||||
if(misc::getPluginVersion(filePath) > misc::getPluginVersion(subDir+file) ) {
|
if(misc::getPluginVersion(shipped_file) > misc::getPluginVersion(destDir+file) ) {
|
||||||
if(QFile::exists(filePath))
|
qDebug("shippped %s is more recent then local plugin, updating", file.toUtf8().data());
|
||||||
QFile::remove(filePath);
|
if(QFile::exists(destDir+file)) {
|
||||||
QFile::copy(filePath, subDir+file);
|
qDebug("Removing old %s", (destDir+file).toUtf8().data());
|
||||||
|
QFile::remove(destDir+file);
|
||||||
|
}
|
||||||
|
qDebug("%s copied to %s", shipped_file.toUtf8().data(), (destDir+file).toUtf8().data());
|
||||||
|
QFile::copy(shipped_file, destDir+file);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Copy icons
|
// Copy icons
|
||||||
if(file.endsWith(".png")) {
|
if(file.endsWith(".png")) {
|
||||||
if(!QFile::exists(subDir+file)) {
|
if(!QFile::exists(destDir+file)) {
|
||||||
QFile::copy(filePath, subDir+file);
|
QFile::copy(shipped_file, destDir+file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// void SearchEngine::novaUpdateDownloaded(QString url, QString filePath){
|
|
||||||
// float version_on_server = getNovaVersion(filePath);
|
|
||||||
// qDebug("Version on qbittorrent.org: %.2f", version_on_server);
|
|
||||||
// float my_version = getNovaVersion(misc::qBittorrentPath()+"nova.py");
|
|
||||||
// if(version_on_server > my_version){
|
|
||||||
// if(QMessageBox::question(this,
|
|
||||||
// tr("Search plugin update -- qBittorrent"),
|
|
||||||
// tr("Search plugin can be updated, do you want to update it?\n\nChangelog:\n")+getNovaChangelog(filePath, my_version),
|
|
||||||
// tr("&Yes"), tr("&No"),
|
|
||||||
// QString(), 0, 1)){
|
|
||||||
// return;
|
|
||||||
// }else{
|
|
||||||
// qDebug("Updating search plugin from qbittorrent.org");
|
|
||||||
// QFile::remove(misc::qBittorrentPath()+"nova.py");
|
|
||||||
// QFile::copy(filePath, misc::qBittorrentPath()+"nova.py");
|
|
||||||
// QFile::Permissions perm=QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | QFile::ReadUser | QFile::WriteUser | QFile::ExeUser | QFile::ReadGroup | QFile::ReadGroup;
|
|
||||||
// QFile(misc::qBittorrentPath()+"nova.py").setPermissions(perm);
|
|
||||||
// }
|
|
||||||
// }else{
|
|
||||||
// if(version_on_server == 0.0){
|
|
||||||
// if(url == "http://www.dchris.eu/nova/nova.zip"){
|
|
||||||
// qDebug("*Warning: Search plugin update download from primary server failed, trying secondary server...");
|
|
||||||
// downloader->downloadUrl("http://hydr0g3n.free.fr/nova/nova.py");
|
|
||||||
// }else{
|
|
||||||
// QMessageBox::information(this, tr("Search plugin update")+" -- "+tr("qBittorrent"),
|
|
||||||
// tr("Sorry, update server is temporarily unavailable."));
|
|
||||||
// }
|
|
||||||
// }else{
|
|
||||||
// QMessageBox::information(this, tr("Search plugin update -- qBittorrent"),
|
|
||||||
// tr("Your search plugin is already up to date."));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // Delete tmp file
|
|
||||||
// QFile::remove(filePath);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void SearchEngine::handleNovaDownloadFailure(QString url, QString reason){
|
|
||||||
// if(url == "http://www.dchris.eu/nova/nova.zip"){
|
|
||||||
// qDebug("*Warning: Search plugin update download from primary server failed, trying secondary server...");
|
|
||||||
// downloader->downloadUrl("http://hydr0g3n.free.fr/nova/nova.py");
|
|
||||||
// }else{
|
|
||||||
// // Display a message box
|
|
||||||
// QMessageBox::critical(0, tr("Search plugin download error"), tr("Couldn't download search plugin update at url: %1, reason: %2.").arg(url).arg(reason));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Slot called when search is Finished
|
// Slot called when search is Finished
|
||||||
// Search can be finished for 3 reasons :
|
// Search can be finished for 3 reasons :
|
||||||
// Error | Stopped by user | Finished normally
|
// Error | Stopped by user | Finished normally
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.00
|
#VERSION: 1.01
|
||||||
#AUTHORS: Fabien Devaux (fab@gnux.info)
|
#AUTHORS: Fabien Devaux (fab@gnux.info)
|
||||||
from novaprinter import prettyPrinter
|
from novaprinter import prettyPrinter
|
||||||
import urllib
|
import urllib
|
||||||
@ -10,10 +10,10 @@ class btjunkie(object):
|
|||||||
name = 'btjunkie'
|
name = 'btjunkie'
|
||||||
|
|
||||||
def search(self, what):
|
def search(self, what):
|
||||||
dat = urllib.urlopen(self.url+'/search?q=%s'%what).read().decode('utf8', 'replace')
|
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
|
# I know it's not very readable, but the SGML parser feels in pain
|
||||||
section_re = re.compile('(?s)href="/torrent\?do=download.*?<tr>')
|
section_re = re.compile('(?s)href="/torrent.*?<tr>')
|
||||||
torrent_re = re.compile('(?s)href="(?P<link>.*?do=download[^"]+).*?'
|
torrent_re = re.compile('(?s)href="(?P<link>.*?[^"]+).*?'
|
||||||
'class="BlckUnd">(?P<name>.*?)</a>.*?'
|
'class="BlckUnd">(?P<name>.*?)</a>.*?'
|
||||||
'>(?P<size>\d+MB)</font>.*?'
|
'>(?P<size>\d+MB)</font>.*?'
|
||||||
'>(?P<seeds>\d+)</font>.*?'
|
'>(?P<seeds>\d+)</font>.*?'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
isohunt: 1.00
|
isohunt: 1.00
|
||||||
torrentreactor: 1.00
|
torrentreactor: 1.00
|
||||||
btjunkie: 1.00
|
btjunkie: 1.01
|
||||||
mininova: 1.00
|
mininova: 1.00
|
||||||
piratebay: 1.00
|
piratebay: 1.00
|
Loading…
Reference in New Issue
Block a user