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 upHow to download only one of the torrents? #801
Comments
This comment has been minimized.
This comment has been minimized.
|
I assume you're asking about how to download one of the files in a torrent. client.add(magnetURI, function(torrent) {
for (const file of torrent.files) {
if (file.path === some_condition) {
file.appendTo('body')
// or...
file.getBuffer(function (buf) {
console.log(buf.toString('hex')) // got raw data
})
}
}
}) |
This comment has been minimized.
This comment has been minimized.
|
Oh I see. So if I want to download only certain files, I have to call |
This comment has been minimized.
This comment has been minimized.
|
You should deselect the rest of files. |
This comment has been minimized.
This comment has been minimized.
|
Right. What @DiegoRBaquero said: file.deselect() |
This comment has been minimized.
This comment has been minimized.
|
@feross @DiegoRBaquero Thanks a ton! Is there a way to list all the selected files (for debugging purposes)? |
This comment has been minimized.
This comment has been minimized.
|
@amilajack You mean files? You could just create an attribute for the file. |
This comment has been minimized.
This comment has been minimized.
|
Yea sorry for the confusion. I edited my comment. I mean to ask how I could list all the files that are being downloaded from a given torrent? Ideally, I'd like to start a torrent, deselect certain files, and then list all the ones that are still selected. |
This comment has been minimized.
This comment has been minimized.
|
The way that selected files are tracked internally (based on byte ranges) would make this information kind of hard to expose, at the moment. I recommend tracking this information manually in your application. |
This comment has been minimized.
This comment has been minimized.
|
This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue. |
I'm having trouble understanding the documentation. How can I download only one of the torrents?
This is what I have so far: