Skip to content

Instantly share code, notes, and snippets.

@kktuax
Last active August 29, 2015 14:18
Show Gist options
  • Save kktuax/a08aec46ebb73f556d1f to your computer and use it in GitHub Desktop.
Save kktuax/a08aec46ebb73f556d1f to your computer and use it in GitHub Desktop.
TorrentStream hash function

Example usage:

node hash.js 'magnet:magnet-uri'

Outputs:

Movie hash: f2213716da24f71b
File size: 274429
File name: My-Movie.mp4
var torrentUrl = process.argv[2];
var torrentStream = require('torrent-stream');
var torrentHash = require('os-torrent-hash');
var engine = torrentStream(torrentUrl);
torrentHash.computeHash(torrentUrl, engine) // engine is a torrent-stream engine
.then(function (res) {
console.log("Movie hash: " + res.movieHash);
console.log("File size: " + res.fileSize);
console.log("File name: " + res.fileName);
process.exit(code=0)
})
.catch(function (error) {
process.exit(code=1)
})
.done();
sudo npm install torrent-stream os-torrent-hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment