mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 20:58:07 -06:00
WebAPI: Add "private" filter for 'info' endpoint
PR #20833. --------- Co-authored-by: Vladimir Golovnev <glassez@yandex.ru> Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
This commit is contained in:
@@ -163,8 +163,7 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent)
|
||||
{KEY_TORRENT_AVAILABILITY, torrent.distributedCopies()},
|
||||
{KEY_TORRENT_REANNOUNCE, torrent.nextAnnounce()},
|
||||
{KEY_TORRENT_COMMENT, torrent.comment()},
|
||||
{KEY_TORRENT_ISPRIVATE, torrent.isPrivate()},
|
||||
|
||||
{KEY_TORRENT_PRIVATE, torrent.isPrivate()},
|
||||
{KEY_TORRENT_TOTAL_SIZE, torrent.totalSize()}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -93,6 +93,6 @@ inline const QString KEY_TORRENT_SEEDING_TIME = u"seeding_time"_s;
|
||||
inline const QString KEY_TORRENT_AVAILABILITY = u"availability"_s;
|
||||
inline const QString KEY_TORRENT_REANNOUNCE = u"reannounce"_s;
|
||||
inline const QString KEY_TORRENT_COMMENT = u"comment"_s;
|
||||
inline const QString KEY_TORRENT_ISPRIVATE = u"is_private"_s;
|
||||
inline const QString KEY_TORRENT_PRIVATE = u"private"_s;
|
||||
|
||||
QVariantMap serialize(const BitTorrent::Torrent &torrent);
|
||||
|
||||
@@ -111,7 +111,8 @@ const QString KEY_PROP_CREATION_DATE = u"creation_date"_s;
|
||||
const QString KEY_PROP_SAVE_PATH = u"save_path"_s;
|
||||
const QString KEY_PROP_DOWNLOAD_PATH = u"download_path"_s;
|
||||
const QString KEY_PROP_COMMENT = u"comment"_s;
|
||||
const QString KEY_PROP_ISPRIVATE = u"is_private"_s;
|
||||
const QString KEY_PROP_IS_PRIVATE = u"is_private"_s; // deprecated, "private" should be used instead
|
||||
const QString KEY_PROP_PRIVATE = u"private"_s;
|
||||
const QString KEY_PROP_SSL_CERTIFICATE = u"ssl_certificate"_s;
|
||||
const QString KEY_PROP_SSL_PRIVATEKEY = u"ssl_private_key"_s;
|
||||
const QString KEY_PROP_SSL_DHPARAMS = u"ssl_dh_params"_s;
|
||||
@@ -282,6 +283,7 @@ void TorrentsController::countAction()
|
||||
// - category (string): torrent category for filtering by it (empty string means "uncategorized"; no "category" param presented means "any category")
|
||||
// - tag (string): torrent tag for filtering by it (empty string means "untagged"; no "tag" param presented means "any tag")
|
||||
// - hashes (string): filter by hashes, can contain multiple hashes separated by |
|
||||
// - private (bool): filter torrents that are from private trackers (true) or not (false). Empty means any torrent (no filtering)
|
||||
// - sort (string): name of column for sorting by its value
|
||||
// - reverse (bool): enable reverse sorting
|
||||
// - limit (int): set limit number of torrents returned (if greater than 0, otherwise - unlimited)
|
||||
@@ -296,6 +298,7 @@ void TorrentsController::infoAction()
|
||||
int limit {params()[u"limit"_s].toInt()};
|
||||
int offset {params()[u"offset"_s].toInt()};
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|', Qt::SkipEmptyParts)};
|
||||
const std::optional<bool> isPrivate = parseBool(params()[u"private"_s]);
|
||||
|
||||
std::optional<TorrentIDSet> idSet;
|
||||
if (!hashes.isEmpty())
|
||||
@@ -305,7 +308,7 @@ void TorrentsController::infoAction()
|
||||
idSet->insert(BitTorrent::TorrentID::fromString(hash));
|
||||
}
|
||||
|
||||
const TorrentFilter torrentFilter {filter, idSet, category, tag};
|
||||
const TorrentFilter torrentFilter {filter, idSet, category, tag, isPrivate};
|
||||
QVariantList torrentList;
|
||||
for (const BitTorrent::Torrent *torrent : asConst(BitTorrent::Session::instance()->torrents()))
|
||||
{
|
||||
@@ -470,7 +473,8 @@ void TorrentsController::propertiesAction()
|
||||
{KEY_PROP_PIECE_SIZE, torrent->pieceLength()},
|
||||
{KEY_PROP_PIECES_HAVE, torrent->piecesHave()},
|
||||
{KEY_PROP_CREATED_BY, torrent->creator()},
|
||||
{KEY_PROP_ISPRIVATE, torrent->isPrivate()},
|
||||
{KEY_PROP_IS_PRIVATE, torrent->isPrivate()}, // used for maintaining backward compatibility
|
||||
{KEY_PROP_PRIVATE, torrent->isPrivate()},
|
||||
{KEY_PROP_ADDITION_DATE, Utils::DateTime::toSecsSinceEpoch(torrent->addedTime())},
|
||||
{KEY_PROP_LAST_SEEN, Utils::DateTime::toSecsSinceEpoch(torrent->lastSeenComplete())},
|
||||
{KEY_PROP_COMPLETION_DATE, Utils::DateTime::toSecsSinceEpoch(torrent->completedTime())},
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#include "base/utils/version.h"
|
||||
#include "api/isessionmanager.h"
|
||||
|
||||
inline const Utils::Version<3, 2> API_VERSION {2, 11, 0};
|
||||
inline const Utils::Version<3, 2> API_VERSION {2, 11, 1};
|
||||
|
||||
class QTimer;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user