Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfisch0920 <fisch0920@gmail.com>2014-05-15 12:11:58 +0400
committerfisch0920 <fisch0920@gmail.com>2014-05-15 12:11:58 +0400
commit24b6fd475901843a8cce7f5519c6637cb27cfb72 (patch)
tree8e78b7bab6f7fa6a9ddc3b21087c785de739361e /index.js
parent25c9080664a9d8814442d2e867dfeee0ff8b3a57 (diff)
added time remaining estimate to console output; several small fixes
Diffstat (limited to 'index.js')
-rw-r--r--index.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/index.js b/index.js
index 5d3e1f8..354f66d 100644
--- a/index.js
+++ b/index.js
@@ -17,7 +17,7 @@ function WebTorrent (opts) {
if (opts.list) {
return
}
-
+
self.on('torrent', function (torrent) {
self._onTorrent(torrent)
})
@@ -26,20 +26,24 @@ function WebTorrent (opts) {
// completed and handle it by stopping fetching additional data from the network
}
-WebTorrent.prototype.add = function (torrentId, cb) {
+WebTorrent.prototype.add = function (torrentId, opts, cb) {
var self = this
+ if (!self.ready) {
+ return self.once('ready', self.add.bind(self, torrentId, opts, cb))
+ }
+
+ if (typeof opts === 'function') {
+ cb = opts
+ opts = {}
+ }
if (typeof cb !== 'function') cb = function () {}
// TODO: support passing in an index to file to download
// self.index = opts.index
- if (!self.ready) {
- return self.once('ready', self.add.bind(self, torrentId, cb))
- }
-
// Called once we have a torrentId that bittorrent-client can handle
function onTorrentId (torrentId) {
- Client.prototype.add.call(self, torrentId, cb)
+ Client.prototype.add.call(self, torrentId, opts, cb)
}
if (Client.toInfoHash(torrentId)) {
@@ -73,6 +77,8 @@ WebTorrent.prototype.add = function (torrentId, cb) {
WebTorrent.prototype._onTorrent = function (torrent) {
var self = this
+ //torrent.swarm.on('wire', function () { })
+
// if no index specified, use largest file
// TODO: support torrent index selection correctly -- this doesn't work yet
/*if (typeof torrent.index !== 'number') {