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

node-save-to-file-system.js « examples - github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a2b1974b78b5e8a781a27b9de4ee900aa55e2470 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var WebTorrent = require('webtorrent')
var fs = require('fs')

var client = new WebTorrent()
var magnetUri = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d'

client.download(magnetUri, function (torrent) {
  // Got torrent metadata!
  console.log('Torrent magnet link:', torrent.magnetURI)

  torrent.files.forEach(function (file) {
    // Stream each file to the disk
    var source = file.createReadStream()
    var destination = fs.createWriteStream(file.name)
    source.pipe(destination)
  })
})