mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-14 02:27:09 -07:00
Support removing tracker from all torrents in WebUI/WebAPI
Closes #20661. PR #21056.
This commit is contained in:
parent
d19f7b12d9
commit
d2b2afad23
8 changed files with 132 additions and 8 deletions
|
@ -969,13 +969,34 @@ void TorrentsController::removeTrackersAction()
|
|||
{
|
||||
requireParams({u"hash"_s, u"urls"_s});
|
||||
|
||||
const auto id = BitTorrent::TorrentID::fromString(params()[u"hash"_s]);
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
const QString hashParam = params()[u"hash"_s];
|
||||
const QStringList urlsParam = params()[u"urls"_s].split(u'|', Qt::SkipEmptyParts);
|
||||
|
||||
const QStringList urls = params()[u"urls"_s].split(u'|');
|
||||
torrent->removeTrackers(urls);
|
||||
QStringList urls;
|
||||
urls.reserve(urlsParam.size());
|
||||
for (const QString &urlStr : urlsParam)
|
||||
urls << QUrl::fromPercentEncoding(urlStr.toLatin1());
|
||||
|
||||
QList<BitTorrent::Torrent *> torrents;
|
||||
|
||||
if (hashParam == u"*"_s)
|
||||
{
|
||||
// remove trackers from all torrents
|
||||
torrents = BitTorrent::Session::instance()->torrents();
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove trackers from specified torrent
|
||||
const auto id = BitTorrent::TorrentID::fromString(hashParam);
|
||||
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->getTorrent(id);
|
||||
if (!torrent)
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
torrents.append(torrent);
|
||||
}
|
||||
|
||||
for (BitTorrent::Torrent *const torrent : asConst(torrents))
|
||||
torrent->removeTrackers(urls);
|
||||
}
|
||||
|
||||
void TorrentsController::addPeersAction()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue