mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-27 06:54:20 +00:00
Merge pull request #9804 from Chocobo1/fix_search
Fix defects in search engine
This commit is contained in:
commit
a57a026f4c
@ -47,6 +47,7 @@
|
|||||||
#include "base/net/downloadmanager.h"
|
#include "base/net/downloadmanager.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/profile.h"
|
#include "base/profile.h"
|
||||||
|
#include "base/utils/bytearray.h"
|
||||||
#include "base/utils/foreignapps.h"
|
#include "base/utils/foreignapps.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
@ -495,33 +496,35 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info)
|
|||||||
{
|
{
|
||||||
QHash<QString, PluginVersion> updateInfo;
|
QHash<QString, PluginVersion> updateInfo;
|
||||||
int numCorrectData = 0;
|
int numCorrectData = 0;
|
||||||
QList<QByteArray> lines = info.split('\n');
|
|
||||||
foreach (QByteArray line, lines) {
|
const QList<QByteArray> lines = Utils::ByteArray::splitToViews(info, "\n", QString::SkipEmptyParts);
|
||||||
|
for (QByteArray line : lines) {
|
||||||
line = line.trimmed();
|
line = line.trimmed();
|
||||||
if (line.isEmpty()) continue;
|
if (line.isEmpty()) continue;
|
||||||
if (line.startsWith('#')) continue;
|
if (line.startsWith('#')) continue;
|
||||||
|
|
||||||
QList<QByteArray> list = line.split(' ');
|
const QList<QByteArray> list = Utils::ByteArray::splitToViews(line, ":", QString::SkipEmptyParts);
|
||||||
if (list.size() != 2) continue;
|
if (list.size() != 2) continue;
|
||||||
|
|
||||||
QString pluginName = QString(list.first());
|
const QString pluginName = list.first().trimmed();
|
||||||
if (!pluginName.endsWith(':')) continue;
|
const PluginVersion version = PluginVersion::tryParse(list.last().trimmed(), {});
|
||||||
|
|
||||||
pluginName.chop(1); // remove trailing ':'
|
if (!version.isValid()) continue;
|
||||||
PluginVersion version = PluginVersion::tryParse(list.last(), {});
|
|
||||||
if (version == PluginVersion()) continue;
|
|
||||||
|
|
||||||
++numCorrectData;
|
++numCorrectData;
|
||||||
if (isUpdateNeeded(pluginName, version)) {
|
if (isUpdateNeeded(pluginName, version)) {
|
||||||
LogMsg(tr("Plugin %1 is outdated").arg(pluginName), Log::INFO);
|
LogMsg(tr("Plugin \"%1\" is outdated, updating to version %2").arg(pluginName, version), Log::INFO);
|
||||||
updateInfo[pluginName] = version;
|
updateInfo[pluginName] = version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numCorrectData < lines.size())
|
if (numCorrectData < lines.size()) {
|
||||||
emit checkForUpdatesFailed(tr("Incorrect update info received for %1 out of %2 plugins.").arg((lines.size() - numCorrectData), lines.size()));
|
emit checkForUpdatesFailed(tr("Incorrect update info received for %1 out of %2 plugins.")
|
||||||
else
|
.arg(QString::number(lines.size() - numCorrectData), QString::number(lines.size())));
|
||||||
|
}
|
||||||
|
else {
|
||||||
emit checkForUpdatesFinished(updateInfo);
|
emit checkForUpdatesFinished(updateInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SearchPluginManager::isUpdateNeeded(QString pluginName, PluginVersion newVersion) const
|
bool SearchPluginManager::isUpdateNeeded(QString pluginName, PluginVersion newVersion) const
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.42
|
#VERSION: 1.43
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Christophe DUMEZ (chris@qbittorrent.org)
|
# Christophe DUMEZ (chris@qbittorrent.org)
|
||||||
@ -90,7 +90,7 @@ def retrieve_url(url):
|
|||||||
charset = 'utf-8'
|
charset = 'utf-8'
|
||||||
try:
|
try:
|
||||||
ignore, charset = info['Content-Type'].split('charset=')
|
ignore, charset = info['Content-Type'].split('charset=')
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
dat = dat.decode(charset, 'replace')
|
dat = dat.decode(charset, 'replace')
|
||||||
dat = htmlentitydecode(dat)
|
dat = htmlentitydecode(dat)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.42
|
#VERSION: 1.43
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Fabien Devaux <fab AT gnux DOT info>
|
# Fabien Devaux <fab AT gnux DOT info>
|
||||||
@ -77,7 +77,7 @@ def initialize_engines():
|
|||||||
# bind class name
|
# bind class name
|
||||||
globals()[engi] = getattr(engine_module, engi)
|
globals()[engi] = getattr(engine_module, engi)
|
||||||
supported_engines.append(engi)
|
supported_engines.append(engi)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return supported_engines
|
return supported_engines
|
||||||
@ -94,7 +94,7 @@ def engines_to_xml(supported_engines):
|
|||||||
if hasattr(search_engine, "supported_categories"):
|
if hasattr(search_engine, "supported_categories"):
|
||||||
supported_categories = " ".join((key
|
supported_categories = " ".join((key
|
||||||
for key in search_engine.supported_categories.keys()
|
for key in search_engine.supported_categories.keys()
|
||||||
if key is not "all"))
|
if key != "all"))
|
||||||
|
|
||||||
yield "".join((tab, "<", short_name, ">\n",
|
yield "".join((tab, "<", short_name, ">\n",
|
||||||
tab, tab, "<name>", search_engine.name, "</name>\n",
|
tab, tab, "<name>", search_engine.name, "</name>\n",
|
||||||
@ -138,7 +138,7 @@ def run_search(engine_list):
|
|||||||
else:
|
else:
|
||||||
engine.search(what)
|
engine.search(what)
|
||||||
return True
|
return True
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.21
|
#VERSION: 1.22
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Christophe DUMEZ (chris@qbittorrent.org)
|
# Christophe DUMEZ (chris@qbittorrent.org)
|
||||||
@ -45,7 +45,7 @@ for engine in engines:
|
|||||||
exec("from engines.%s import %s" % (e, e))
|
exec("from engines.%s import %s" % (e, e))
|
||||||
exec("engine_url = %s.url" % e)
|
exec("engine_url = %s.url" % e)
|
||||||
supported_engines[engine_url] = e
|
supported_engines[engine_url] = e
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.46
|
#VERSION: 1.47
|
||||||
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions are met:
|
# modification, are permitted provided that the following conditions are met:
|
||||||
@ -51,13 +51,13 @@ def anySizeToBytes(size_string):
|
|||||||
# separate integer from unit
|
# separate integer from unit
|
||||||
try:
|
try:
|
||||||
size, unit = size_string.split()
|
size, unit = size_string.split()
|
||||||
except:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
size = size_string.strip()
|
size = size_string.strip()
|
||||||
unit = ''.join([c for c in size if c.isalpha()])
|
unit = ''.join([c for c in size if c.isalpha()])
|
||||||
if len(unit) > 0:
|
if len(unit) > 0:
|
||||||
size = size[:-len(unit)]
|
size = size[:-len(unit)]
|
||||||
except:
|
except Exception:
|
||||||
return -1
|
return -1
|
||||||
if len(size) == 0:
|
if len(size) == 0:
|
||||||
return -1
|
return -1
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.41
|
#VERSION: 1.42
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Christophe DUMEZ (chris@qbittorrent.org)
|
# Christophe DUMEZ (chris@qbittorrent.org)
|
||||||
@ -90,7 +90,7 @@ def retrieve_url(url):
|
|||||||
charset = 'utf-8'
|
charset = 'utf-8'
|
||||||
try:
|
try:
|
||||||
ignore, charset = info['Content-Type'].split('charset=')
|
ignore, charset = info['Content-Type'].split('charset=')
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
dat = dat.decode(charset, 'replace')
|
dat = dat.decode(charset, 'replace')
|
||||||
dat = htmlentitydecode(dat)
|
dat = htmlentitydecode(dat)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.42
|
#VERSION: 1.43
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Fabien Devaux <fab AT gnux DOT info>
|
# Fabien Devaux <fab AT gnux DOT info>
|
||||||
@ -76,7 +76,7 @@ def initialize_engines():
|
|||||||
# bind class name
|
# bind class name
|
||||||
globals()[engi] = getattr(engine_module, engi)
|
globals()[engi] = getattr(engine_module, engi)
|
||||||
supported_engines.append(engi)
|
supported_engines.append(engi)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return supported_engines
|
return supported_engines
|
||||||
@ -93,7 +93,7 @@ def engines_to_xml(supported_engines):
|
|||||||
if hasattr(search_engine, "supported_categories"):
|
if hasattr(search_engine, "supported_categories"):
|
||||||
supported_categories = " ".join((key
|
supported_categories = " ".join((key
|
||||||
for key in search_engine.supported_categories.keys()
|
for key in search_engine.supported_categories.keys()
|
||||||
if key is not "all"))
|
if key != "all"))
|
||||||
|
|
||||||
yield "".join((tab, "<", short_name, ">\n",
|
yield "".join((tab, "<", short_name, ">\n",
|
||||||
tab, tab, "<name>", search_engine.name, "</name>\n",
|
tab, tab, "<name>", search_engine.name, "</name>\n",
|
||||||
@ -138,7 +138,7 @@ def run_search(engine_list):
|
|||||||
engine.search(what)
|
engine.search(what)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#VERSION: 1.21
|
#VERSION: 1.22
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Christophe DUMEZ (chris@qbittorrent.org)
|
# Christophe DUMEZ (chris@qbittorrent.org)
|
||||||
@ -45,7 +45,7 @@ for engine in engines:
|
|||||||
exec("from engines.%s import %s" % (e, e))
|
exec("from engines.%s import %s" % (e, e))
|
||||||
exec("engine_url = %s.url" % e)
|
exec("engine_url = %s.url" % e)
|
||||||
supported_engines[engine_url] = e
|
supported_engines[engine_url] = e
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user