Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebAPI: optionally include trackers list in torrent info response #22128

Conversation

zze0s
Copy link
Contributor

@zze0s zze0s commented Jan 8, 2025

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 key trackers.

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 be TORRENT_ something instead.

I just copied the private bool param so it behaves the same but it could potentially be changed to includes=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.

@glassez glassez added the WebAPI WebAPI-related issues/changes label Jan 9, 2025
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
@glassez
Copy link
Member

glassez commented Jan 10, 2025

Not sure if getStickyTrackers() should be included or not.

These aren't real trackers. Does it make sense in the output of this API endpoint?

@zze0s
Copy link
Contributor Author

zze0s commented Jan 10, 2025

Not that I can think of. Only the real trackers are useful.

Ok to remove then? 👍

@zze0s zze0s requested a review from Chocobo1 January 11, 2025 11:07
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
src/webui/api/torrentscontroller.cpp Outdated Show resolved Hide resolved
@Chocobo1 Chocobo1 added this to the 5.1 milestone Jan 13, 2025
@Chocobo1 Chocobo1 merged commit 76e1040 into qbittorrent:master Jan 17, 2025
14 checks passed
@Chocobo1
Copy link
Member

@zze0s
Thank you!

@zze0s zze0s deleted the feature/torrentlist-optional-include-trackers branch January 18, 2025 10:45
@CarlosLanderas
Copy link

@zze0s thanks for the contribution! Tremendously useful to avoid fetching all trackers by every torrent hash 👌👌

Chocobo1 added a commit that referenced this pull request Jan 24, 2025
This is another optimization for torrent management on large scale instances with the goal to minimize the amount of required API calls. Ref #22128.

This new function and endpoint torrents/setTags does an upsert to replace the torrent tags and handles the removal and add internally, instead of doing multiple calls to add and remove tags on torrents from the client.

PR #22156.

---------

Co-authored-by: Chocobo1 <[email protected]>
Co-authored-by: Vladimir Golovnev <[email protected]>
@zze0s
Copy link
Contributor Author

zze0s commented Jan 24, 2025

@CarlosLanderas ❤️ once this and #22156 lands in new versions and tools/libraries are updated it will make a huge difference for big instances! 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebAPI WebAPI-related issues/changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants