How to select only one file (Webtorrent/Node)

Viewed 13

I am trying to get webtorrent to download only the .mp4 but it is downloading everything else.

app.post('/download', (req, res) => {
console.log("torrent started")
const client = new WebTorrent()
const magnetURI = req.body.magnet

client.add(magnetURI, { path: './assets' }, function (torrent) {
     
    torrent._selections = []
    const file = torrent.files.find(file => file.name.endsWith('.mp4'))
    
    file.select() // doesn't work

    torrent.on('done', function () {
      console.log('torrent download finished')
    })
     
})
client.on('error', function (err) {
    console.log(err.toString())
})

})

0 Answers
Related