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

Feature Request: control select/deselect default on new torrents #873

Open
retrohacker opened this issue Jul 23, 2016 · 4 comments
Open

Feature Request: control select/deselect default on new torrents #873

retrohacker opened this issue Jul 23, 2016 · 4 comments

Comments

@retrohacker
Copy link
Contributor

@retrohacker retrohacker commented Jul 23, 2016

I've seen this raised several times (i.e. #758), and I would find it useful for PeerWeb.

When a new torrent is added to a client, it has the files in the torrent set to selected by default. It would be nice to be able to change this so you could fetch the metadata and then control which files you want to download at what priority from there.

This would clean up the logic when you need a single file from a massive torrent (>1k files).

I would like to propose adding a setting to the opts of client.add that would allow you to control whether the files in a torrent are selected or deselected by default:

client.add(torrentId, [opts], [function ontorrent (torrent) {}])

Start downloading a new torrent.

torrentId can be one of:

  • magnet uri (string)
  • torrent file (buffer)
  • info hash (hex string or buffer)
  • parsed torrent (from parse-torrent)
  • http/https url to a torrent file (string)
  • filesystem path to a torrent file (string) (Node.js only)

If opts is specified, then the default options (shown below) will be overridden.

{
  announce: [],              // Torrent trackers to use (added to list in .torrent or magnet uri)
  getAnnounceOpts: Function, // Custom callback to allow sending extra parameters to the tracker
  maxWebConns: Number,       // Max number of simultaneous connections per web seed [default=4]
  path: String,              // Folder to download files to (default=`/tmp/webtorrent/`)
  store: Function,           // Custom chunk store (must follow [abstract-chunk-store](https://www.npmjs.com/package/abstract-chunk-store) API)
  startDownload: Boolean     // Automatically start downloading the files once metadata is available
}

If ontorrent is specified, then it will be called when this torrent is ready to be
used (i.e. metadata is available). Note: this is distinct from the 'torrent' event which
will fire for all torrents.

If you want access to the torrent object immediately in order to listen to events as the
metadata is fetched from the network, then use the return value of client.add. If you
just want the file data, then use ontorrent or the 'torrent' event.

If you provide opts.store, it will be called as
opts.store(chunkLength, storeOpts) with:

  • storeOpts.length - size of all the files in the torrent
  • storeOpts.files - an array of torrent file objects
  • storeOpts.torrent - the torrent instance being stored
@retrohacker

This comment has been minimized.

Copy link
Contributor Author

@retrohacker retrohacker commented Jul 23, 2016

Again, happy to do the legwork on implementing this if it seems like a sane thing to do.

@vankasteelj

This comment has been minimized.

Copy link

@vankasteelj vankasteelj commented Nov 23, 2016

I would actually like if we could set all files deselected by default. The .select() or .deselect() file api calls seem pretty heavy on a slow CPU like an Atom Z3735, and as I only play 1 video file at a time, I usually have to deselect all files, then reselect the one I wanna play, which, in case of a 8 to 20 files torrent can take between 5 and 30 sec (on an atom again, on an i5 it goes nearly instant).

@maxogden

This comment has been minimized.

Copy link

@maxogden maxogden commented Feb 1, 2017

@retrohacker did you ever find a workaround for this?

edit i found this workaround, will try #164 (comment)

@stale

This comment has been minimized.

Copy link

@stale stale bot commented May 3, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 3, 2018
@feross feross added enhancement accepted and removed stale labels May 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.