Torrent reader, writer, and hash checker for node.
HEALTH ? 98 / Healthy
Torrent reader, writer, and hash checker for node.
// momentum
// why it's here
// how to help
// readme
Read, make, and hash check torrents with node.js!
const nt = require('nt');
nt.read('path/to/file.torrent', (err, torrent) => {
if (err) throw err;
console.log('Info hash:', torrent.infoHash());
});
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!');
});
let hasher = torrent.hashCheck(file);
let p;
hasher.on('match', (i, hash, percent) => {
p = percent;
});
hasher.on('end', () => {
console.log('Hash Check:', p + '%', 'matched');
});