diff options
author | fisch0920 <fisch0920@gmail.com> | 2014-05-16 12:43:18 +0400 |
---|---|---|
committer | fisch0920 <fisch0920@gmail.com> | 2014-05-16 12:43:18 +0400 |
commit | da72f6bbe213f98575e1bf01f6cd17ee331bcf53 (patch) | |
tree | ac66940f4ddb11fa38d5427a79f3209f4f12a761 /bin | |
parent | 1529dcff555bba3abe9a67e93d030548fdb8863f (diff) |
adding FSStorage; webtorrent now can save the results of a torrent download to the filesystem
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cmd.js | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -6,7 +6,6 @@ var cp = require('child_process') var fs = require('fs') var http = require('http') var minimist = require('minimist') -var os = require('os') var path = require('path') var numeral = require('numeral') var address = require('network-address') @@ -14,8 +13,6 @@ var moment = require('moment') var proc = require('child_process') var WebTorrent = require('../') -var TMP = os.tmp - function usage () { var logo = fs.readFileSync(path.join(__dirname, 'ascii-logo.txt'), 'utf8') logo.split('\n').forEach(function (line) { @@ -35,11 +32,12 @@ function usage () { console.log('') console.log(' -p, --port change the http port [default: 9000]') console.log(' -l, --list list available files in torrent') + console.log(' -n, --no-quit do not quit peerflix on vlc exit') + console.log(' -r, --remove remove any downloaded files on exit') console.log(' -t, --subtitles load subtitles file') console.log(' -h, --help display this help message') console.log(' -q, --quiet silence stdout') console.log(' -v, --version print the current version') - console.log(' -n, --no-quit do not quit peerflix on vlc exit') console.log('') } @@ -105,7 +103,22 @@ client.server.once('listening', function () { listening = true }) -client.add(torrentId, function (err, torrent) { +if (argv.remove || argv.r) { + function remove () { + client.destroy(function () { + process.nextTick(function () { + process.exit() + }) + }) + } + + process.on('SIGINT', remove) + process.on('SIGTERM', remove) +} + +client.add(torrentId, { + remove: argv.remove || argv.r +}, function (err, torrent) { if (err) { clivas.line('{red:error} ' + err.message) process.exit(1) @@ -258,3 +271,4 @@ client.on('torrent', function (torrent) { }) } }) + |