Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upGet Peers without downloading file #1397
Comments
This comment has been minimized.
This comment has been minimized.
|
Hey @GooG2e, To search for peers, you must know the infoHash of the torrent you are looking for, because of this the torrent must always be added to the client, but you can disable the downloading of the torrent when it's added to the client, allowing the discovery and connection to peers, but preventing downloading anything till you need it. You could achieve this two ways, firstly manually deselecting the torrent: var sintel = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent'
var torrent = client.add(sintel)
torrent.on('metadata', t=>{
// Deselect all pieces so nothing is downloaded.
t.deselect(0, t.pieces.length - 1, false)
})Secondly this could be achieved with the newly implemented BEP, BEP 53, you could specify the magnetURI parameter var sintel = 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent'
// Select no files to download
var selectOnly = '&so='
var torrent = client.add(sintel + selectOnly)Both examples given will start downloading the needed pieces when All the best :) |
Hello!
I have a question - can webtorrent looking for peers without downloading
I think this can speed up init - user opens web page and peer search initialize and when it start playing then we have peers and can instantly use them