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:
-rw-r--r--.gitignore2
-rw-r--r--itty-bitty.js31
2 files changed, 33 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index a72b52e..7c6bf20 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,5 @@ results
npm-debug.log
node_modules
+
+tmp \ No newline at end of file
diff --git a/itty-bitty.js b/itty-bitty.js
new file mode 100644
index 0000000..eff2dbe
--- /dev/null
+++ b/itty-bitty.js
@@ -0,0 +1,31 @@
+// Download a torrent with itty-bitty-torrent
+
+var path = require('path')
+
+var Torrent = require('itty-bitty-torrent')
+var downloadLocation = path.join(__dirname, 'tmp')
+// var torrent = 'http://releases.ubuntu.com/13.10/ubuntu-13.10-server-amd64.iso.torrent'
+// var torrent = path.join(__dirname, 'torrents/leaves.torrent')
+var torrent = path.join(__dirname, 'torrents/pride.torrent')
+
+var client = new Torrent(torrent, downloadLocation, function(err){
+ if (!err) client.download()
+
+ // Get speed
+ setInterval(function(){
+ console.log(Math.round(client.speed()) / 1000)
+ }, 500)
+
+ // Get percentage downloaded
+ setInterval(function(){
+ console.log(Math.round(client.percentage()))
+ }, 10000)
+})
+
+client.on('finished', function(){
+ console.log('finished')
+ // The torrent has finished downloading.
+})
+
+// stop our torrent downloading & seeding
+// client.stop() \ No newline at end of file