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: 5b33d0cbdc59cccf48386191560ed54bc584283f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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)
  })
})