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:
authorFeross Aboukhadijeh <feross@feross.org>2014-10-14 11:13:51 +0400
committerFeross Aboukhadijeh <feross@feross.org>2014-10-14 11:13:51 +0400
commit0eb35e63b71e72857637e1bc86e213aed0ff4175 (patch)
tree9c9f8353159b62a08c9f6ec90ebc61148194ad33 /bin
parentb02c8ba10883d961897719d53583637215607c92 (diff)
Use --index to pick video file to stream (fix #150)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cmd.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/bin/cmd.js b/bin/cmd.js
index 795f5a3..20c9f96 100755
--- a/bin/cmd.js
+++ b/bin/cmd.js
@@ -30,6 +30,7 @@ var argv = minimist(process.argv.slice(2), {
b: 'blocklist',
t: 'subtitles',
l: 'list',
+ i: 'index',
n: 'no-quit',
r: 'remove',
q: 'quiet',
@@ -92,7 +93,8 @@ if (argv.help || !torrentId) {
-p, --port [number] change the http port [default: 9000]
-b, --blocklist [path] use the specified blocklist
-t, --subtitles [file] load subtitles file
- -l, --list list available files in torrent
+ -l, --list list available files in torrent (with indexes)
+ -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
-q, --quiet silence stdout
@@ -182,10 +184,21 @@ torrent.on('ready', function () {
var filename, swarm, wires
function onTorrent (torrent) {
+ client.torrent = torrent
+
filename = torrent.name
swarm = torrent.swarm
wires = torrent.swarm.wires
+ // if no index specified, use largest file
+ var index = (typeof argv.index === 'number')
+ ? argv.index
+ : torrent.files.indexOf(torrent.files.reduce(function (a, b) {
+ return a.length > b.length ? a : b
+ }))
+ client.index = index
+ torrent.files[index].select()
+
if (argv.list) {
torrent.files.forEach(function (file, i) {
clivas.line('{3+bold:' + i + '} : {magenta:' + file.name + '}')