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

Add without starting download? #255

Closed
btmdave opened this issue Jan 28, 2015 · 4 comments
Closed

Add without starting download? #255

btmdave opened this issue Jan 28, 2015 · 4 comments
Labels

Comments

@btmdave
Copy link

@btmdave btmdave commented Jan 28, 2015

Is there anyway to add a torrent and get it's info, but not start downloading?

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Jan 28, 2015

From the command line you can list the files in a torrent using the --list option:

$ webtorrent --list "magnet:?xt=urn:btih:a97cf38232f073cbe83c34197437edfd702237c0&dn=Sintel+4k+UHD+ENG+FLAC+ITA+ENG+Sub+DMRip+1744p+X265+ZMachine&xl=3489948077&dl=3489948077"

0   : Sintel.4k.UHD.ENG.FLAC.ITA.ENG.Sub.DMRip.1744p.X265_ZMachine.mkv (3.49 GB)

From the API, there's no simple way to do this at the moment, but you can print out the metadata and then remove the torrent from the client. That would do the trick.

var WebTorrent = require('webtorrent')
var client = new WebTorrent()
client.add(magnetUri, function (torrent) {
  console.log(torrent.parsedTorrent) // or torrent.metadata, torrent.files, etc.  
  client.remove(torrent)
})
@Svenskunganka

This comment has been minimized.

Copy link

@Svenskunganka Svenskunganka commented Jan 29, 2015

@feross how would I go with getting seeder / leecher list from a set of trackers in an array (or from a parsed torrent) without downloading the torrent? I'm a bit confused on this one.

Thanks in advance!

@alexeisavca

This comment has been minimized.

Copy link
Contributor

@alexeisavca alexeisavca commented May 18, 2015

How about

client.add(magnetUri, function (torrent) {
  torrent.files.forEach(file => file.deselect())
})

That way you wouldn't be downloading any files, but still stay in the swarm, i guess. Would that work?

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Jul 1, 2015

@Svenskunganka Please open a new issue for your question (it has nothing to do with this issue).

@alexeisavca You solution would work 👍

@btmdave You can do this:

client.add(torrentId, function (torrent) {
  // gets called once we have the torrent metadata
  console.log(torrent.files) // access the metadata, etc.
  torrent.destroy()
})

The callback is called as soon as the client has the torrent metadata (and before downloading has started), so destroying the torrent immediately will allow you to just access the metadata.

@feross feross closed this Jul 1, 2015
@feross feross added the question label Jul 1, 2015
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.