mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 21:28:07 -06:00
@@ -266,6 +266,21 @@ void SearchEngine::cancelSearch()
|
||||
}
|
||||
}
|
||||
|
||||
void SearchEngine::downloadTorrent(const QString &siteUrl, const QString &url)
|
||||
{
|
||||
QProcess *downloadProcess = new QProcess(this);
|
||||
downloadProcess->setEnvironment(QProcess::systemEnvironment());
|
||||
connect(downloadProcess, SIGNAL(finished(int)), this, SLOT(torrentFileDownloadFinished(int)));
|
||||
m_downloaders << downloadProcess;
|
||||
QStringList params {
|
||||
Utils::Fs::toNativePath(engineLocation() + "/nova2dl.py"),
|
||||
siteUrl,
|
||||
url
|
||||
};
|
||||
// Launch search
|
||||
downloadProcess->start(Utils::Misc::pythonExecutable(), params, QIODevice::ReadOnly);
|
||||
}
|
||||
|
||||
void SearchEngine::startSearch(const QString &pattern, const QString &category, const QStringList &usedPlugins)
|
||||
{
|
||||
// Search process already running or
|
||||
@@ -357,6 +372,21 @@ void SearchEngine::pluginDownloadFailed(const QString &url, const QString &reaso
|
||||
emit pluginInstallationFailed(pluginName, tr("Failed to download the plugin file. %1").arg(reason));
|
||||
}
|
||||
|
||||
void SearchEngine::torrentFileDownloadFinished(int exitcode)
|
||||
{
|
||||
QProcess *downloadProcess = static_cast<QProcess*>(sender());
|
||||
if (exitcode == 0) {
|
||||
QString line = QString::fromUtf8(downloadProcess->readAllStandardOutput()).trimmed();
|
||||
QStringList parts = line.split(' ');
|
||||
if (parts.size() == 2)
|
||||
emit torrentFileDownloaded(parts[0]);
|
||||
}
|
||||
|
||||
qDebug() << "Deleting downloadProcess";
|
||||
m_downloaders.removeOne(downloadProcess);
|
||||
downloadProcess->deleteLater();
|
||||
}
|
||||
|
||||
// Update nova.py search plugin if necessary
|
||||
void SearchEngine::updateNova()
|
||||
{
|
||||
@@ -383,6 +413,12 @@ void SearchEngine::updateNova()
|
||||
QFile::copy(":/" + novaFolder + "/nova2.py", filePath);
|
||||
}
|
||||
|
||||
filePath = searchDir.absoluteFilePath("nova2dl.py");
|
||||
if (getPluginVersion(":/" + novaFolder + "/nova2dl.py") > getPluginVersion(filePath)) {
|
||||
removePythonScriptIfExists(filePath);
|
||||
QFile::copy(":/" + novaFolder + "/nova2dl.py", filePath);
|
||||
}
|
||||
|
||||
filePath = searchDir.absoluteFilePath("fix_encoding.py");
|
||||
QFile::copy(":/" + novaFolder + "/fix_encoding.py", filePath);
|
||||
|
||||
|
||||
@@ -84,6 +84,8 @@ public:
|
||||
void startSearch(const QString &pattern, const QString &category, const QStringList &usedPlugins);
|
||||
void cancelSearch();
|
||||
|
||||
void downloadTorrent(const QString &siteUrl, const QString &url);
|
||||
|
||||
static qreal getPluginVersion(QString filePath);
|
||||
static QString categoryFullName(const QString &categoryName);
|
||||
static QString pluginsLocation();
|
||||
@@ -102,6 +104,8 @@ signals:
|
||||
void checkForUpdatesFinished(const QHash<QString, qreal> &updateInfo);
|
||||
void checkForUpdatesFailed(const QString &reason);
|
||||
|
||||
void torrentFileDownloaded(const QString &path);
|
||||
|
||||
private slots:
|
||||
void onTimeout();
|
||||
void readSearchOutput();
|
||||
@@ -110,6 +114,7 @@ private slots:
|
||||
void versionInfoDownloadFailed(const QString &url, const QString &reason);
|
||||
void pluginDownloaded(const QString &url, QString filePath);
|
||||
void pluginDownloadFailed(const QString &url, const QString &reason);
|
||||
void torrentFileDownloadFinished(int exitcode);
|
||||
|
||||
private:
|
||||
void update();
|
||||
@@ -132,6 +137,7 @@ private:
|
||||
bool m_searchStopped;
|
||||
QTimer *m_searchTimeout;
|
||||
QByteArray m_searchResultLineTruncated;
|
||||
QList<QProcess*> m_downloaders;
|
||||
};
|
||||
|
||||
#endif // SEARCHENGINE_H
|
||||
|
||||
Reference in New Issue
Block a user