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 upList all torrents api #1028
List all torrents api #1028
Comments
This comment has been minimized.
This comment has been minimized.
|
You should be getting an empty array. Do you really get undefined??? See index.js#L86 |
This comment has been minimized.
This comment has been minimized.
|
@atmoner Can you share your complete code? Without that we can't really help you. |
This comment has been minimized.
This comment has been minimized.
|
@feross of course! The contextI code from electron The code is very basic:
Webtorrent + my soft so 2 torrents runing but out of log give just one In my example, I try to log the torrents from the add function but I would like to be able to call it outside of this function. |
This comment has been minimized.
This comment has been minimized.
|
I believe you're using the wrong terminology. You are trying to print the number of peers, but what you are actually printing is the number of torrents. A torrent is a set of files that are shared via the BitTorrent protocol. Try this: var client = new WebTorrent()
var torrentId = 'https://webtorrent.io/torrents/sintel.torrent'
var torrent = client.add(torrentId)
// Note: we refer to "peers" as "wires" in the WebTorrent codebase sometimes
torrent.on('wire', function (wire) {
console.log('Now connected to ' + torrent.numPeers + ' peers')
if (wire.remoteAddress) {
console.log(wire.remoteAddress + ':' + wire.remotePort)
}
}) |
This comment has been minimized.
This comment has been minimized.
No no ^^ I am really trying to display the list of torrents active in webtorrent (if it is possible obviously) ...
For the connect peers it's ok, Webtorrent does very well this spot on a torrent but my final goal would be to create a mini torrent client with the simple functionality of webtorrent.
I almost do everything except the list of torrents! |
This comment has been minimized.
This comment has been minimized.
|
I don't understand why you expect your snippet to return more than 1 torrent. You're only adding 1 torrent to the client. var torrentId = 'https://webtorrent.io/torrents/sintel.torrent'
var client = new WebTorrent()
var util = require('util')
client.add(torrentId, function (torrent) {
console.log(Array.isArray(client.torrents)); // return true
client.torrents.forEach(function(element) {
console.log(element.name); // Return only sintel.mp4
}); |
This comment has been minimized.
This comment has been minimized.
|
On my screen I add a torrent from my software and a torrent with webtorrent-cli. But return only 1 torrent
Ah! it's my another question, Can I add several torrent at once? |
This comment has been minimized.
This comment has been minimized.
|
Done for me! You had pointed out The right mistake, It was enough to add a second torrent as a result Code work:
|
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. |


What version of WebTorrent?
WebTorrent 1.9.0 (0.98.3)
What operating system and Node.js version?
Ubuntu 16.04 & Node v7.4.0
What browser and version? (if using WebTorrent in the browser)
No browser, in electron
What did you expect to happen?
For now, I try the function client.torrents but it returns me only the name of the torrent currently in action