webtorrent/parse-torrent

From .torrent to magnet link

KeizerDev opened this issue · 3 comments

How can I get from this:

parseTorrent.remote(torrentId, function (err, parsedTorrent) {
  if (err) throw err
  console.log(parsedTorrent)
})

To a magnet link?

What is torrentId in this example? Is it a .torrent file?

Once you have a parsedTorrent, you can use magnet-uri:

var magnet = require('magnet-uri')

var uri = magnet.encode(parsedTorrent)

console.log(uri) // the magnet uri 

https://www.npmjs.com/package/magnet-uri

Thanks 😃