|
|
@ -117,6 +117,8 @@ const char KEY_FILE_AVAILABILITY[] = "availability"; |
|
|
|
namespace |
|
|
|
namespace |
|
|
|
{ |
|
|
|
{ |
|
|
|
using Utils::String::parseBool; |
|
|
|
using Utils::String::parseBool; |
|
|
|
|
|
|
|
using Utils::String::parseInt; |
|
|
|
|
|
|
|
using Utils::String::parseDouble; |
|
|
|
|
|
|
|
|
|
|
|
void applyToTorrents(const QStringList &hashes, const std::function<void (BitTorrent::Torrent *torrent)> &func) |
|
|
|
void applyToTorrents(const QStringList &hashes, const std::function<void (BitTorrent::Torrent *torrent)> &func) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -601,6 +603,8 @@ void TorrentsController::pieceStatesAction() |
|
|
|
void TorrentsController::addAction() |
|
|
|
void TorrentsController::addAction() |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QString urls = params()["urls"]; |
|
|
|
const QString urls = params()["urls"]; |
|
|
|
|
|
|
|
const QString cookie = params()["cookie"]; |
|
|
|
|
|
|
|
|
|
|
|
const bool skipChecking = parseBool(params()["skip_checking"]).value_or(false); |
|
|
|
const bool skipChecking = parseBool(params()["skip_checking"]).value_or(false); |
|
|
|
const bool seqDownload = parseBool(params()["sequentialDownload"]).value_or(false); |
|
|
|
const bool seqDownload = parseBool(params()["sequentialDownload"]).value_or(false); |
|
|
|
const bool firstLastPiece = parseBool(params()["firstLastPiecePrio"]).value_or(false); |
|
|
|
const bool firstLastPiece = parseBool(params()["firstLastPiecePrio"]).value_or(false); |
|
|
@ -608,10 +612,11 @@ void TorrentsController::addAction() |
|
|
|
const QString savepath = params()["savepath"].trimmed(); |
|
|
|
const QString savepath = params()["savepath"].trimmed(); |
|
|
|
const QString category = params()["category"]; |
|
|
|
const QString category = params()["category"]; |
|
|
|
const QSet<QString> tags = List::toSet(params()["tags"].split(',', QString::SkipEmptyParts)); |
|
|
|
const QSet<QString> tags = List::toSet(params()["tags"].split(',', QString::SkipEmptyParts)); |
|
|
|
const QString cookie = params()["cookie"]; |
|
|
|
|
|
|
|
const QString torrentName = params()["rename"].trimmed(); |
|
|
|
const QString torrentName = params()["rename"].trimmed(); |
|
|
|
const int upLimit = params()["upLimit"].toInt(); |
|
|
|
const int upLimit = parseInt(params()["upLimit"]).value_or(-1); |
|
|
|
const int dlLimit = params()["dlLimit"].toInt(); |
|
|
|
const int dlLimit = parseInt(params()["dlLimit"]).value_or(-1); |
|
|
|
|
|
|
|
const double ratioLimit = parseDouble(params()["ratioLimit"]).value_or(BitTorrent::Torrent::USE_GLOBAL_RATIO); |
|
|
|
|
|
|
|
const int seedingTimeLimit = parseInt(params()["seedingTimeLimit"]).value_or(BitTorrent::Torrent::USE_GLOBAL_SEEDING_TIME); |
|
|
|
const std::optional<bool> autoTMM = parseBool(params()["autoTMM"]); |
|
|
|
const std::optional<bool> autoTMM = parseBool(params()["autoTMM"]); |
|
|
|
|
|
|
|
|
|
|
|
const QString contentLayoutParam = params()["contentLayout"]; |
|
|
|
const QString contentLayoutParam = params()["contentLayout"]; |
|
|
@ -636,20 +641,22 @@ void TorrentsController::addAction() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BitTorrent::AddTorrentParams params; |
|
|
|
BitTorrent::AddTorrentParams addTorrentParams; |
|
|
|
// TODO: Check if destination actually exists
|
|
|
|
// TODO: Check if destination actually exists
|
|
|
|
params.skipChecking = skipChecking; |
|
|
|
addTorrentParams.skipChecking = skipChecking; |
|
|
|
params.sequential = seqDownload; |
|
|
|
addTorrentParams.sequential = seqDownload; |
|
|
|
params.firstLastPiecePriority = firstLastPiece; |
|
|
|
addTorrentParams.firstLastPiecePriority = firstLastPiece; |
|
|
|
params.addPaused = addPaused; |
|
|
|
addTorrentParams.addPaused = addPaused; |
|
|
|
params.contentLayout = contentLayout; |
|
|
|
addTorrentParams.contentLayout = contentLayout; |
|
|
|
params.savePath = savepath; |
|
|
|
addTorrentParams.savePath = savepath; |
|
|
|
params.category = category; |
|
|
|
addTorrentParams.category = category; |
|
|
|
params.tags = tags; |
|
|
|
addTorrentParams.tags = tags; |
|
|
|
params.name = torrentName; |
|
|
|
addTorrentParams.name = torrentName; |
|
|
|
params.uploadLimit = (upLimit > 0) ? upLimit : -1; |
|
|
|
addTorrentParams.uploadLimit = upLimit; |
|
|
|
params.downloadLimit = (dlLimit > 0) ? dlLimit : -1; |
|
|
|
addTorrentParams.downloadLimit = dlLimit; |
|
|
|
params.useAutoTMM = autoTMM; |
|
|
|
addTorrentParams.seedingTimeLimit = seedingTimeLimit; |
|
|
|
|
|
|
|
addTorrentParams.ratioLimit = ratioLimit; |
|
|
|
|
|
|
|
addTorrentParams.useAutoTMM = autoTMM; |
|
|
|
|
|
|
|
|
|
|
|
bool partialSuccess = false; |
|
|
|
bool partialSuccess = false; |
|
|
|
for (QString url : asConst(urls.split('\n'))) |
|
|
|
for (QString url : asConst(urls.split('\n'))) |
|
|
@ -658,7 +665,7 @@ void TorrentsController::addAction() |
|
|
|
if (!url.isEmpty()) |
|
|
|
if (!url.isEmpty()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Net::DownloadManager::instance()->setCookiesFromUrl(cookies, QUrl::fromEncoded(url.toUtf8())); |
|
|
|
Net::DownloadManager::instance()->setCookiesFromUrl(cookies, QUrl::fromEncoded(url.toUtf8())); |
|
|
|
partialSuccess |= BitTorrent::Session::instance()->addTorrent(url, params); |
|
|
|
partialSuccess |= BitTorrent::Session::instance()->addTorrent(url, addTorrentParams); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -671,7 +678,7 @@ void TorrentsController::addAction() |
|
|
|
, tr("Error: '%1' is not a valid torrent file.").arg(it.key())); |
|
|
|
, tr("Error: '%1' is not a valid torrent file.").arg(it.key())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
partialSuccess |= BitTorrent::Session::instance()->addTorrent(torrentInfo, params); |
|
|
|
partialSuccess |= BitTorrent::Session::instance()->addTorrent(torrentInfo, addTorrentParams); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (partialSuccess) |
|
|
|
if (partialSuccess) |
|
|
|