magnet-to-torrent
convert magnet link to torrent download link
Last updated 5 years ago by lwhiteley .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install magnet-to-torrent 
SYNC missed versions from official npm registry.

magnet-to-torrent

convert a magnet uri to a torrent download link

Install

npm install --save magnet-to-torrent

How to use

var magnetToTorrent = require('magnet-to-torrent');

var magnet = '< a valid magnet uri >';
magnetToTorrent.getLink(magnet)
    .then( function(torrentLink){
        console.log(torrentLink); // torrent url as string
    })
    .catch(function(error){
        console.error(error); // couldn't get a valid link
    });

Check if URI is a Magnet URI

The following verifies if the magnet uri provided is formatted correctly.

var bool = magnetToTorrent.isMagnet(magnet); // returns boolean

Default Services Used

The library will attempt to retrieve a working torrent link from the following services, respectively:

Adding a Conversion Service

Each service takes in hash as a parameter and uses it to build the download link in the format of how the said service allows a user to download torrents. The library tests if the torrent is cached by the service and responds with the first url that has the torrent available.

You can add your own service before attempting to convert magnets.

See snippet below.

eg.

var service = function(hash){
    return `http://reflektor.karmorra.info/torrent/${hash}.torrent`;
};

magnetToTorrent.addService(service);

/**
 OR:
 Optionally, use a second parameter to push the service to the top of the stack
 This will ensure your service is called first
**/
magnetToTorrent.addService(service, true);

Notes:

  • hash is the torrent hash extracted from the magnet uri
  • This is an experiment but should work fine.

Report any issues.

Credits

Current Tags

  • 1.0.8                                ...           latest (a year ago)

20 Versions

  • 1.0.8                                ...           a year ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.9                                ...           5 years ago
  • 0.0.8                                ...           5 years ago
  • 0.0.7                                ...           5 years ago
  • 0.0.6                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 1
Dependencies (5)
Dev Dependencies (0)
None

Copyright 2014 - 2017 © taobao.org |