webtorrent-cli
Advanced tools
Comparing version 3.0.7 to 3.0.8
@@ -40,2 +40,3 @@ # Authors | ||
- Diego Rodríguez <diegorbaquero@gmail.com> | ||
- Dong, Xingda <dxingda@gatech.edu> | ||
- Vijayanand Nandam <vijay@cybrilla.com> | ||
@@ -51,4 +52,5 @@ - Jashandeep Sohi <jashandeep.s.sohi@gmail.com> | ||
- ksnikiforov <kirnik77@gmail.com> | ||
- Alex <alxmorais8@msn.com> | ||
#### Generated by tools/update-authors.sh. | ||
100
bin/cmd.js
@@ -180,3 +180,3 @@ #!/usr/bin/env node | ||
let client, href, server, serving | ||
let client, href, server, serving, numTorrents | ||
@@ -205,23 +205,11 @@ if (['info', 'create', 'download', 'add', 'seed'].includes(command) && argv._.length === 1) { | ||
const torrentIds = argv._.slice(1) | ||
if (torrentIds.length > 1) { | ||
handleMultipleInputs(torrentIds) | ||
} | ||
processInputs(torrentIds) | ||
torrentIds.forEach(torrentId => runDownload(torrentId)) | ||
} else if (command === 'downloadmeta') { | ||
const torrentIds = argv._.slice(1) | ||
if (torrentIds.length > 1) { | ||
handleMultipleInputs(torrentIds) | ||
} | ||
processInputs(torrentIds) | ||
torrentIds.forEach(torrentId => runDownloadMeta(torrentId)) | ||
} else if (command === 'seed') { | ||
const inputs = argv._.slice(1) | ||
if (inputs.length > 1) { | ||
handleMultipleInputs(inputs) | ||
} | ||
processInputs(inputs) | ||
inputs.forEach(input => runSeed(input)) | ||
@@ -231,7 +219,3 @@ } else if (command) { | ||
const torrentIds = argv._ | ||
if (torrentIds.length > 1) { | ||
handleMultipleInputs(torrentIds) | ||
} | ||
processInputs(torrentIds) | ||
torrentIds.forEach(torrentId => runDownload(torrentId)) | ||
@@ -242,3 +226,6 @@ } else { | ||
function handleMultipleInputs (inputs) { | ||
function processInputs (inputs) { | ||
numTorrents = inputs.length | ||
if (inputs.length === 1) return | ||
// These arguments do not make sense when downloading multiple torrents, or | ||
@@ -380,7 +367,13 @@ // seeding multiple files/folders. | ||
client = new WebTorrent({ blocklist: argv.blocklist }) | ||
client = new WebTorrent({ | ||
blocklist: argv.blocklist, | ||
torrentPort: argv['torrent-port'], | ||
dhtPort: argv['dht-port'] | ||
}) | ||
client.on('error', fatalError) | ||
const { out: path, announce } = argv | ||
const torrent = client.add(torrentId, { path, announce }) | ||
const torrent = client.add(torrentId, { | ||
path: argv.out, | ||
announce: argv.announce | ||
}) | ||
@@ -416,2 +409,4 @@ torrent.on('infoHash', () => { | ||
torrent.on('done', () => { | ||
numTorrents -= 1 | ||
if (!argv.quiet) { | ||
@@ -428,3 +423,11 @@ const numActiveWires = torrent.wires | ||
torrentDone() | ||
if (argv['on-done']) { | ||
cp.exec(argv['on-done']).unref() | ||
} | ||
if (!playerName && !serving && argv.out && !argv['keep-seeding'] && numTorrents === 0) { | ||
gracefulExit() | ||
} else if (!argv['keep-seeding']) { | ||
torrent.destroy() | ||
} | ||
}) | ||
@@ -619,3 +622,7 @@ | ||
client = new WebTorrent({ blocklist: argv.blocklist }) | ||
client = new WebTorrent({ | ||
blocklist: argv.blocklist, | ||
torrentPort: argv['torrent-port'], | ||
dhtPort: argv['dht-port'] | ||
}) | ||
client.on('error', fatalError) | ||
@@ -667,9 +674,11 @@ | ||
const client = new WebTorrent({ blocklist: argv.blocklist }) | ||
const client = new WebTorrent({ | ||
blocklist: argv.blocklist, | ||
torrentPort: argv['torrent-port'], | ||
dhtPort: argv['dht-port'] | ||
}) | ||
client.on('error', fatalError) | ||
client.seed(input, { | ||
announce: argv.announce, | ||
torrentPort: argv['torrent-port'], | ||
dhtPort: argv['dht-port'] | ||
announce: argv.announce | ||
}, torrent => { | ||
@@ -720,16 +729,9 @@ if (argv.quiet) { | ||
if (seeding) { | ||
line(`{green:Info hash: }${torrent.infoHash}`) | ||
const seedingInfo = [] | ||
if (argv['torrent-port']) { | ||
seedingInfo.push(`{green:Torrent port: }${argv['torrent-port']}`) | ||
} | ||
if (argv['dht-port']) { | ||
seedingInfo.push(`{green:DHT port: }${argv['dht-port']}`) | ||
} | ||
if (seedingInfo.length) { | ||
line(seedingInfo.join(' ')) | ||
} | ||
} | ||
if (seeding) line(`{green:Info hash: }${torrent.infoHash}`) | ||
const portInfo = [] | ||
if (argv['torrent-port']) portInfo.push(`{green:Torrent port: }${argv['torrent-port']}`) | ||
if (argv['dht-port']) portInfo.push(`{green:DHT port: }${argv['dht-port']}`) | ||
if (portInfo.length) line(portInfo.join(' ')) | ||
if (playerName) { | ||
@@ -846,12 +848,2 @@ line(`{green:Streaming to: }{bold:${playerName}} {green:Server running at: }{bold:${href}}`) | ||
function torrentDone () { | ||
if (argv['on-done']) { | ||
cp.exec(argv['on-done']).unref() | ||
} | ||
if (!playerName && !serving && argv.out && !argv['keep-seeding']) { | ||
gracefulExit() | ||
} | ||
} | ||
function fatalError (err) { | ||
@@ -858,0 +850,0 @@ clivas.line(`{red:Error:} ${err.message || err}`) |
{ | ||
"name": "webtorrent-cli", | ||
"description": "WebTorrent, the streaming torrent client. For the command line.", | ||
"version": "3.0.7", | ||
"version": "3.0.8", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "WebTorrent LLC", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33583
727