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: 1d5e7e6afdce89c972e6c72524b2ef7446809a6e (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: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)
  })
})