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:
Diffstat (limited to 'examples/node-save-to-file-system.js')
-rw-r--r--examples/node-save-to-file-system.js33
1 files changed, 17 insertions, 16 deletions
diff --git a/examples/node-save-to-file-system.js b/examples/node-save-to-file-system.js
index 5b33d0c..1d5e7e6 100644
--- a/examples/node-save-to-file-system.js
+++ b/examples/node-save-to-file-system.js
@@ -1,16 +1,17 @@
-var WebTorrent = require('webtorrent')
-var fs = require('fs')
-
-var client = new WebTorrent()
-
-client.download(magnet_uri, function (torrent) {
- // Got torrent metadata!
- console.log('Torrent info hash:', torrent.infoHash)
-
- torrent.files.forEach(function (file) {
- // Stream each file to the disk
- var source = file.createReadStream()
- var destination = fs.createWriteStream(file.name)
- source.pipe(destination)
- })
-})
+var WebTorrent = require('webtorrent')
+var fs = require('fs')
+
+var client = new WebTorrent()
+var magnetUri = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36'
+
+client.download(magnetUri, function (torrent) {
+ // Got torrent metadata!
+ console.log('Torrent info hash:', torrent.infoHash)
+
+ torrent.files.forEach(function (file) {
+ // Stream each file to the disk
+ var source = file.createReadStream()
+ var destination = fs.createWriteStream(file.name)
+ source.pipe(destination)
+ })
+})