// momentum

tracking since W47

// why it's here

  • Active: last commit today
  • Around since 2011 and still shipping

// how to help

// readme

node-torrent

Read, make, and hash check torrents with node.js!

Usage

Read a torrent

const nt = require('nt');

nt.read('path/to/file.torrent', (err, torrent) => {
  if (err) throw err;
  console.log('Info hash:', torrent.infoHash());
});

Make a torrent

const fs = require('node:fs');
const nt = require('nt');

let rs = nt.make('http://myannounce.net/url', __dirname + '/files');
rs.pipe(fs.createWriteStream('mytorrent.torrent'));

// from a stream, without a directory
nt.make('http://myannounce.net/url', fs.createReadStream('video.mp4'))
  .pipe(fs.createWriteStream('video.torrent'));

// callback style
nt.makeWrite('outputfile', 'http://announce.me', __dirname + '/files',
  ['somefile.ext', 'another.one', 'inside/afolder.mkv', 'afolder'],
  (err, torrent) => {
    if (err) throw err;
    console.log('Finished writing torrent!');
  });

Hash check a torrent

let hasher = torrent.hashCheck(file);

let p;
hasher.on('match', (i, hash, percent) => {
  p = percent;
});

hasher.on('end', () => {
  console.log('Hash Check:', p + '%', 'matched');
});
Read the full README on GitHub โ†—