diff --git a/WebAPI_Changelog.md b/WebAPI_Changelog.md index 4dd39c4a8..ac372fa79 100644 --- a/WebAPI_Changelog.md +++ b/WebAPI_Changelog.md @@ -4,6 +4,8 @@ * [#22932](https://github.com/qbittorrent/qBittorrent/pull/22932) * `torrents/categories` and `sync/maindata` now serialize categories' `downloadPath` to `null`, rather than `undefined` +* [#22954](https://github.com/qbittorrent/qBittorrent/pull/22954) + * `torrents/reannounce` supports specifying individual trackers via `trackers` field ## 2.11.9 diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index bb3e98a31..310f7c405 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -1618,10 +1618,30 @@ void TorrentsController::reannounceAction() requireParams({u"hashes"_s}); const QStringList hashes {params()[u"hashes"_s].split(u'|')}; - applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) + const QStringList urlsParam {params()[u"urls"_s].split(u'|', Qt::SkipEmptyParts)}; + + QSet urls; + urls.reserve(urlsParam.size()); + for (const QString &urlStr : urlsParam) + urls << QUrl::fromPercentEncoding(urlStr.toLatin1()); + + applyToTorrents(hashes, [&urls](BitTorrent::Torrent *const torrent) { - torrent->forceReannounce(); - torrent->forceDHTAnnounce(); + if (urls.isEmpty()) + { + torrent->forceReannounce(); + torrent->forceDHTAnnounce(); + } + else + { + const QList &trackers = torrent->trackers(); + for (qsizetype i = 0; i < trackers.size(); ++i) + { + const BitTorrent::TrackerEntryStatus &status = trackers.at(i); + if (urls.contains(status.url)) + torrent->forceReannounce(i); + } + } }); setResult(QString()); diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index cabeb72d0..8ba14dd6a 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -248,6 +248,8 @@
  • QBT_TR(Edit tracker URL...)QBT_TR[CONTEXT=TrackerListWidget] QBT_TR(Edit tracker URL...)QBT_TR[CONTEXT=TrackerListWidget]
  • QBT_TR(Remove tracker)QBT_TR[CONTEXT=TrackerListWidget] QBT_TR(Remove tracker)QBT_TR[CONTEXT=TrackerListWidget]
  • QBT_TR(Copy tracker URL)QBT_TR[CONTEXT=TrackerListWidget] QBT_TR(Copy tracker URL)QBT_TR[CONTEXT=TrackerListWidget]
  • +
  • QBT_TR(Copy tracker URL)QBT_TR[CONTEXT=TrackerListWidget] QBT_TR(Force reannounce to selected tracker(s))QBT_TR[CONTEXT=TrackerListWidget]
  • +
  • QBT_TR(Copy tracker URL)QBT_TR[CONTEXT=TrackerListWidget] QBT_TR(Force reannounce to all trackers)QBT_TR[CONTEXT=TrackerListWidget]