|
|
@ -320,11 +320,12 @@ void TorrentsController::propertiesAction() |
|
|
|
requireParams({"hash"}); |
|
|
|
requireParams({"hash"}); |
|
|
|
|
|
|
|
|
|
|
|
const QString hash {params()["hash"]}; |
|
|
|
const QString hash {params()["hash"]}; |
|
|
|
QJsonObject dataDict; |
|
|
|
|
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
if (!torrent) |
|
|
|
if (!torrent) |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QJsonObject dataDict; |
|
|
|
|
|
|
|
|
|
|
|
dataDict[KEY_PROP_TIME_ELAPSED] = torrent->activeTime(); |
|
|
|
dataDict[KEY_PROP_TIME_ELAPSED] = torrent->activeTime(); |
|
|
|
dataDict[KEY_PROP_SEEDING_TIME] = torrent->seedingTime(); |
|
|
|
dataDict[KEY_PROP_SEEDING_TIME] = torrent->seedingTime(); |
|
|
|
dataDict[KEY_PROP_ETA] = static_cast<double>(torrent->eta()); |
|
|
|
dataDict[KEY_PROP_ETA] = static_cast<double>(torrent->eta()); |
|
|
@ -422,11 +423,11 @@ void TorrentsController::webseedsAction() |
|
|
|
requireParams({"hash"}); |
|
|
|
requireParams({"hash"}); |
|
|
|
|
|
|
|
|
|
|
|
const QString hash {params()["hash"]}; |
|
|
|
const QString hash {params()["hash"]}; |
|
|
|
QJsonArray webSeedList; |
|
|
|
|
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
if (!torrent) |
|
|
|
if (!torrent) |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QJsonArray webSeedList; |
|
|
|
for (const QUrl &webseed : asConst(torrent->urlSeeds())) { |
|
|
|
for (const QUrl &webseed : asConst(torrent->urlSeeds())) { |
|
|
|
webSeedList.append(QJsonObject { |
|
|
|
webSeedList.append(QJsonObject { |
|
|
|
{KEY_WEBSEED_URL, webseed.toString()} |
|
|
|
{KEY_WEBSEED_URL, webseed.toString()} |
|
|
@ -451,11 +452,11 @@ void TorrentsController::filesAction() |
|
|
|
requireParams({"hash"}); |
|
|
|
requireParams({"hash"}); |
|
|
|
|
|
|
|
|
|
|
|
const QString hash {params()["hash"]}; |
|
|
|
const QString hash {params()["hash"]}; |
|
|
|
QJsonArray fileList; |
|
|
|
|
|
|
|
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
if (!torrent) |
|
|
|
if (!torrent) |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QJsonArray fileList; |
|
|
|
if (torrent->hasMetadata()) { |
|
|
|
if (torrent->hasMetadata()) { |
|
|
|
const QVector<BitTorrent::DownloadPriority> priorities = torrent->filePriorities(); |
|
|
|
const QVector<BitTorrent::DownloadPriority> priorities = torrent->filePriorities(); |
|
|
|
const QVector<qreal> fp = torrent->filesProgress(); |
|
|
|
const QVector<qreal> fp = torrent->filesProgress(); |
|
|
@ -494,11 +495,11 @@ void TorrentsController::pieceHashesAction() |
|
|
|
requireParams({"hash"}); |
|
|
|
requireParams({"hash"}); |
|
|
|
|
|
|
|
|
|
|
|
const QString hash {params()["hash"]}; |
|
|
|
const QString hash {params()["hash"]}; |
|
|
|
QJsonArray pieceHashes; |
|
|
|
|
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
if (!torrent) |
|
|
|
if (!torrent) |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QJsonArray pieceHashes; |
|
|
|
const QVector<QByteArray> hashes = torrent->info().pieceHashes(); |
|
|
|
const QVector<QByteArray> hashes = torrent->info().pieceHashes(); |
|
|
|
for (const QByteArray &hash : hashes) |
|
|
|
for (const QByteArray &hash : hashes) |
|
|
|
pieceHashes.append(QString(hash.toHex())); |
|
|
|
pieceHashes.append(QString(hash.toHex())); |
|
|
@ -516,11 +517,11 @@ void TorrentsController::pieceStatesAction() |
|
|
|
requireParams({"hash"}); |
|
|
|
requireParams({"hash"}); |
|
|
|
|
|
|
|
|
|
|
|
const QString hash {params()["hash"]}; |
|
|
|
const QString hash {params()["hash"]}; |
|
|
|
QJsonArray pieceStates; |
|
|
|
|
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
if (!torrent) |
|
|
|
if (!torrent) |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QJsonArray pieceStates; |
|
|
|
const QBitArray states = torrent->pieces(); |
|
|
|
const QBitArray states = torrent->pieces(); |
|
|
|
for (int i = 0; i < states.size(); ++i) |
|
|
|
for (int i = 0; i < states.size(); ++i) |
|
|
|
pieceStates.append(static_cast<int>(states[i]) * 2); |
|
|
|
pieceStates.append(static_cast<int>(states[i]) * 2); |
|
|
@ -609,7 +610,6 @@ void TorrentsController::addTrackersAction() |
|
|
|
requireParams({"hash", "urls"}); |
|
|
|
requireParams({"hash", "urls"}); |
|
|
|
|
|
|
|
|
|
|
|
const QString hash = params()["hash"]; |
|
|
|
const QString hash = params()["hash"]; |
|
|
|
|
|
|
|
|
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
if (!torrent) |
|
|
|
if (!torrent) |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
@ -669,12 +669,12 @@ void TorrentsController::removeTrackersAction() |
|
|
|
requireParams({"hash", "urls"}); |
|
|
|
requireParams({"hash", "urls"}); |
|
|
|
|
|
|
|
|
|
|
|
const QString hash = params()["hash"]; |
|
|
|
const QString hash = params()["hash"]; |
|
|
|
const QStringList urls = params()["urls"].split('|'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); |
|
|
|
if (!torrent) |
|
|
|
if (!torrent) |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
throw APIError(APIErrorType::NotFound); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QStringList urls = params()["urls"].split('|'); |
|
|
|
|
|
|
|
|
|
|
|
const QVector<BitTorrent::TrackerEntry> trackers = torrent->trackers(); |
|
|
|
const QVector<BitTorrent::TrackerEntry> trackers = torrent->trackers(); |
|
|
|
QVector<BitTorrent::TrackerEntry> remainingTrackers; |
|
|
|
QVector<BitTorrent::TrackerEntry> remainingTrackers; |
|
|
|
remainingTrackers.reserve(trackers.size()); |
|
|
|
remainingTrackers.reserve(trackers.size()); |
|
|
|