Tribler / tribler

Privacy enhanced BitTorrent client with P2P content discovery
https://www.tribler.org
GNU General Public License v3.0
4.86k stars 451 forks source link

Limit max amount of active downloads #3724

Open Thomasedv opened 6 years ago

Thomasedv commented 6 years ago

Make Tribler limit the amount of active downloads (and potentially uploads) to favor speed for certain torrents. Batch adding a large number of torrents may take many hours before the first torrent is fully downloaded, and if you could tell tribler to only take the 3 at a time, would greatly shorten the time before the first torrent is downloaded. As the user may want one torrent before the others, e.g. the first episode of a series. (If the episodes aren't all in one torrent)

Right now, the user needs to manually stop and start all the torrents themselves. And without batch selecting in the GUI, it quickly becomes a hassle, as well has having to remember to start the next ones afterwards.

Update:

The same concept can also be applied to torrents on the same disk when doing a check, right now, all of them will be checked at the same time, and that could cause a loss of reading speed as it has to read many files from many locations at once. Right now, the waiting for check state seems to not be used, at least not in that way as i can start tribler and will check all at once. It's smarter to quickly finish one torrent so that it can start downloading earlier, than have all take longer and waste time that could have been used for downloading something.

Dmole commented 6 years ago

Could be scripted thought the RPC API untill it's implemented.

heldersepu commented 5 years ago

I raised this before: issue #608 in the comment the made it look as if it was an easy task:

Comment from @NielsZeilemaker

We should be able to implement/expose this in the gui, as libtorrent allows us to do exactly this: http://www.rasterbar.com/products/libtorrent/manual.html#queuing

Comment from @egbertbouman

GUI stuff should be simple. Besides that, we only need to turn on auto-management on for all torrents and it should work.

But the issue was closed as wontfix, I hope that

heldersepu commented 5 years ago

Could be scripted thought the RPC API untill it's implemented.

@Dmole Can you provide a sample script?

Dmole commented 5 years ago

Could be scripted thought the RPC API until it's implemented.

@Dmole Can you provide a sample script?

https://tribler.readthedocs.io/en/next/restapi/downloads.html So something like

T=http://localhost:8085
while read -r H ; do
    curl -X PUT "$T/torrents/$H/start"
done < <(curl -X GET "$T/downloads?get_peers=0&get_pieces=0" | grep infohash)

I left out string sanitation, and the limiting logic for brevity, but the main issue is; the documentation is lacking so you would have to look at the source for the correct start/stop commands.

heldersepu commented 5 years ago

@Dmole Thanks for the docs link, ye that documentation is not the best, but I think I can hack my way from there...

Do you see this feature been added any time soon?

devos50 commented 5 years ago

I made some improvements to the documentation in #4521.

heldersepu commented 5 years ago

@devos50 Improvements are good! take a look here: https://tribler.readthedocs.io/en/next/restapi/downloads.html#Tribler.Core.Modules.restapi.downloads_endpoint.DownloadsEndpoint

Examples include getting all downloads, starting, pausing and stopping downloads.

But there are no such examples, either add examples or remove that statement


A description of the possible download statuses can be found in the REST API documentation.

This is the documentation, right? if there is another documentation a link should be provided

Dmole commented 5 years ago

@heldersepu

BTW source is here

https://github.com/Tribler/tribler/tree/master/Tribler/Core/Modules/restapi

Tested example:

#!/bin/bash

#
# tribler_stop_all.sh
#

T=http://localhost:8085
while read -r H ; do
    curl -sX PATCH "$T/downloads/$H" --data "state=stop" > /dev/null
done < <(curl -sX GET "$T/downloads" | python -m json.tool | grep infohash | perl -pe 's/.*: "//g;s/".*//g')
heldersepu commented 5 years ago

@Dmole here is the bash script I put together for queueing: https://github.com/heldersepu/hs-scripts/blob/master/Bash/tribler_queue.sh

ichorid commented 4 years ago

We should consider adding an option to enable Libtorrent automanagement. Or even enable it by default. Need to discuss this.