Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

magnet-link

ungoldman61ISC1.1.3

Get a magnet link from a torrent file.

link, magnet, magnet-link, read-torrent, torrent, torrenting

readme

magnet-link

Get a magnet link from a torrent file.

npm travis standard downloads

Read more about the magnet URI scheme at the magnet-uri project website.

Install

npm install magnet-link

Usage

Node

var magnetLink = require('magnet-link')

magnetLink('http://my-server.com/file.torrent', function (err, link) {
  if (err) throw err
  console.log(link)
  // you got a magnet link from a remote torrent file
})

magnetLink('mydir/file.torrent', function (err, link) {
  if (err) throw err
  console.log(link)
  // you got a magnet link from a local torrent file
})

The result is a string that looks like this.

magnet:?xt=urn:btih:[torrent-info-hash]

CLI

There is also a command-line interface available if you install it with -g.

npm install -g magnet-link

This installs a program called magnet-link that you simply pass a torrent file or url.

magnet-link http://my-server.com/file.torrent

This will print the magnet link to the terminal.

Pipes

You can also pipe the contents of a torrent file to magnet-link:

cat file.torrent | magnet-link
magnet-link < file.torrent

This way it can be paired with create-torrent:

create-torrent . | magnet-link

Contributing

Contributions welcome! Please read the contributing guidelines before getting started.

License

ISC

changelog

magnet-link change log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

1.1.3 - 2018-02-14

Fixes

  • deps: remove dumb typo

1.1.2 - 2018-02-14

Maintenance

  • update package metadata
  • update documentation
  • update contributing guidelines
  • update license
  • update dependencies
  • update dev dependencies
  • update tests

1.1.1 - 2016-02-07

  • allow for piping without - option

1.1.0 - 2016-02-07

  • make bin/cli.js executable (chmod +x)
  • make torrent file contents pipable to magnet-link -

1.0.4 - 2015-04-07

  • renamed scripts to test since it only contains test script
  • various sundry readme updates
  • improved test script task
  • update dependencies
  • add CONTRIBUTING.md
  • update .travis.yml to use docker & cache node_modules

1.0.3 - 2015-01-28

  • improve test coverage
  • move cli.js to bin
  • specify files for distribution

1.0.2 - 2015-01-28

  • fix travis badge

1.0.1 - 2015-01-28

  • use standard for npm test
  • use fixpack for true insanity
  • add .travis.yml
  • add tests
  • fix a rather serious error in index

1.0.0 - 2015-01-23

  • first!