Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorfisch0920 <fisch0920@gmail.com>2014-05-16 12:43:18 +0400
committerfisch0920 <fisch0920@gmail.com>2014-05-16 12:43:18 +0400
commitda72f6bbe213f98575e1bf01f6cd17ee331bcf53 (patch)
treeac66940f4ddb11fa38d5427a79f3209f4f12a761 /bin
parent1529dcff555bba3abe9a67e93d030548fdb8863f (diff)
adding FSStorage; webtorrent now can save the results of a torrent download to the filesystem
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cmd.js24
1 files changed, 19 insertions, 5 deletions
diff --git a/bin/cmd.js b/bin/cmd.js
index 95bc2df..6fc0f03 100755
--- a/bin/cmd.js
+++ b/bin/cmd.js
@@ -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) {
})
}
})
+