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/browser-download.js')
-rw-r--r--examples/browser-download.js45
1 files changed, 23 insertions, 22 deletions
diff --git a/examples/browser-download.js b/examples/browser-download.js
index 3428f72..a60e3bd 100644
--- a/examples/browser-download.js
+++ b/examples/browser-download.js
@@ -1,22 +1,23 @@
-var WebTorrent = require('webtorrent')
-
-var client = new WebTorrent()
-
-client.add(magnet_uri, function (torrent) {
- // Got torrent metadata!
- console.log('Torrent info hash:', torrent.infoHash)
-
- torrent.files.forEach(function (file) {
- // Get a url for each file
- file.getBlobURL(function (err, url) {
- if (err) throw err
-
- // Add a link to the page
- var a = document.createElement('a')
- a.download = file.name
- a.href = url
- a.textContent = 'Download ' + file.name
- document.body.appendChild(a)
- })
- })
-})
+var WebTorrent = require('webtorrent')
+
+var client = new WebTorrent()
+var magnetUri = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36'
+
+client.add(magnetUri, function (torrent) {
+ // Got torrent metadata!
+ console.log('Torrent info hash:', torrent.infoHash)
+
+ torrent.files.forEach(function (file) {
+ // Get a url for each file
+ file.getBlobURL(function (err, url) {
+ if (err) throw err
+
+ // Add a link to the page
+ var a = document.createElement('a')
+ a.download = file.name
+ a.href = url
+ a.textContent = 'Download ' + file.name
+ document.body.appendChild(a)
+ })
+ })
+})