WebAPI: optionally include trackers list in torrent info response #22128
+33
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds an optional parameter
includeTrackers
to the Torrent info endpoint/torrents/info
to include the trackers list of each torrent in the response under the keytrackers
.Why?
Me and a lot of other users runs anything between 1-40k torrents in a single instance and we rely on various tools to do things like tag by different tracker states.
To get the trackers we have to first get the list of torrents and then loop through that to get the trackers per torrent. With 10k torrents that's 10000+1 requests towards qBitorrent. It does handle it fairly well but it feels a bit wrong to spam it like that.
With this change we'll be able to get all that info in a single call (or few calls with pagination). It will most likely reduce the overall load quite a bit.
About the code
This is my first time touching c++ and making any changes to this codebase but I read the contributing guidelines etc so it should be to spec.
Not sure if
KEY_PROP_TRACKERS
is the correct one to set or if it should beTORRENT_
something instead.I just copied the
private
bool param so it behaves the same but it could potentially be changed toincludes=trackers,other
which takes a comma separated string of other things that could be of interest to include.The trackers logic is just a copy paste from the getTrackers endpoint. Not sure if
getStickyTrackers()
should be included or not.I tested it locally and it works as expected with and without the new
includeTrackers
query param.