forked from dessalines/torrent-tracker-health
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·30 lines (28 loc) · 1.07 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env node
var torrentHealth = require('./index.js'),
argv = require('minimist')(process.argv.slice(2));
if (argv._.length !== 0 || !argv.torrent) {
console.error([
'Usage: torrent-tracker-health [options]',
' --torrent: the torrent file, magnet link, torrent dir, or a file of line-delimited list of infohashes',
' --trackers= [Optional] {tracker1/announce, tracker2/announce}, uses a default list otherwise',
' --batchSize: [Optional] The number of torrents to include in the scrape request (Default 50)',
' --showAllFetches: [Optional] Shows all the scrapes, instead of choosing the one with the most seeders(Default false)',
' --debug: [Optional] (Default false)',
].join('\n'));
process.exit(1);
} else {
var opts = {
batchSize: argv.batchSize,
trackers: argv.trackers,
showAllFetches: argv.showAllFetches,
debug: argv.debug
}
if (argv.torrent) {
torrentHealth(argv.torrent, opts).then(r => {
console.log(JSON.stringify(r, null, 2));
}).catch(function (err) {
console.log('error:', err);
});
}
}