diff --git a/bin/cmd.js b/bin/cmd.js index 4c7a19d9..e52b2572 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -30,6 +30,7 @@ var argv = minimist(process.argv.slice(2), { i: 'index', n: 'no-quit', r: 'remove', + o: 'out', q: 'quiet', h: 'help', v: 'version' @@ -94,6 +95,7 @@ if (argv.help || !torrentId) { -i, --index stream a particular file from torrnet (by index) -n, --no-quit do not quit webtorrent on vlc exit -r, --remove remove downloaded files on exit + -o, --out [path] overrides the default tmp directory -q, --quiet silence stdout -h, --help display this help message -v, --version print the current version @@ -154,7 +156,7 @@ function remove (cb) { client.destroy(cb) } -var torrent = client.add(torrentId) +var torrent = client.add(torrentId, (argv.out ? { tmp: argv.out } : {})) torrent.on('infoHash', function () { function updateMetadata () { diff --git a/index.js b/index.js index 3ad617b1..e8404cdc 100644 --- a/index.js +++ b/index.js @@ -144,6 +144,8 @@ WebTorrent.prototype.download = function (torrentId, opts, ontorrent) { opts.client = self opts.storage = opts.storage || self.storage + if(opts.tmp) opts.storageOpts = { tmp: opts.tmp }; + var torrent = new Torrent(torrentId, extend({ client: self }, opts)) self.torrents.push(torrent)