New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add time remaining estimate and minor fixes #56
Merged
+448
−73
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
24b6fd4
added time remaining estimate to console output; several small fixes
transitive-bullshit b784a88
merge changes
transitive-bullshit f98a3fd
removed extraneous comment
transitive-bullshit 1529dcf
stream to VLC is now working
transitive-bullshit da72f6b
adding FSStorage; webtorrent now can save the results of a torrent do…
transitive-bullshit d6d66ec
added small optimization to FSStorage.readBlock to read blocks from i…
transitive-bullshit 196d9ee
support peer blocklist
transitive-bullshit 976fd11
added missing commandline blocklist parsing for blocklist support
transitive-bullshit a1afa10
.
transitive-bullshit 8021381
fixed possibility of hanging process on --remove and fixed an error i…
transitive-bullshit File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
Loading status checks…
stream to VLC is now working
- Loading branch information
| @@ -11,6 +11,7 @@ var path = require('path') | ||
| var numeral = require('numeral') | ||
| var address = require('network-address') | ||
| var moment = require('moment') | ||
| var proc = require('child_process') | ||
|
||
| var WebTorrent = require('../') | ||
|
|
||
| var TMP = os.tmp | ||
| @@ -38,6 +39,7 @@ function usage () { | ||
| 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('') | ||
| } | ||
|
|
||
| @@ -49,6 +51,7 @@ var port = Number(argv.port || argv.p) || 9000 | ||
| var list = argv.list || argv.l | ||
| var subtitles = argv.subtitles || argv.t | ||
| var quiet = argv.quiet || argv.q | ||
| var noquit = argv.n || argv['no-quit'] | ||
|
|
||
| if (argv.help || argv.h) { | ||
| usage() | ||
| @@ -66,6 +69,7 @@ if (!torrentId) { | ||
| } | ||
|
|
||
| var VLC_ARGS = '-q --video-on-top --play-and-exit' | ||
| //var VLC_ARGS = '--video-on-top --play-and-exit --extraintf=http:logger --verbose=2 --file-logging --logfile=vlc-log.txt' | ||
| var OMX_EXEC = 'omxplayer -r -o ' + (typeof argv.omx === 'string') | ||
| ? argv.omx + ' ' | ||
| : 'hdmi ' | ||
| @@ -82,10 +86,25 @@ var client = new WebTorrent({ | ||
| quiet: true | ||
| }) | ||
|
|
||
| var started = Date.now() | ||
| var listening = false | ||
|
|
||
| client.on('error', function (err) { | ||
| clivas.line('{red:error} ' + err.message) | ||
| }) | ||
|
|
||
| client.once('ready', function () { | ||
| client.server.once('error', function () { | ||
| client.server.listen(0) | ||
transitive-bullshit
Author
Member
|
||
| }) | ||
|
|
||
| client.server.listen(port) | ||
| }) | ||
|
|
||
| client.server.once('listening', function () { | ||
| listening = true | ||
| }) | ||
|
|
||
| client.add(torrentId, function (err, torrent) { | ||
| if (err) { | ||
| clivas.line('{red:error} ' + err.message) | ||
| @@ -109,7 +128,7 @@ client.add(torrentId, function (err, torrent) { | ||
| } | ||
| }) | ||
|
|
||
| client.once('torrent', function (torrent) { | ||
| function ontorrent (torrent) { | ||
| if (list) { | ||
| torrent.files.forEach(function (file, i) { | ||
| clivas.line('{3+bold:'+i+'} : {magenta:'+file.name+'}') | ||
| @@ -118,22 +137,7 @@ client.once('torrent', function (torrent) { | ||
| process.exit(0) | ||
| } | ||
|
|
||
| var started = Date.now() | ||
| var swarm = torrent.swarm | ||
| var wires = swarm.wires | ||
| var hotswaps = 0 | ||
|
|
||
| torrent.on('hotswap', function () { | ||
| hotswaps++ | ||
| }) | ||
|
|
||
| function active (wire) { | ||
| return !wire.peerChoking | ||
| } | ||
|
|
||
| var href = 'http://' + address() + ':' + swarm.port + '/' | ||
| //var filename = engine.server.index.name.split('/').pop().replace(/\{|\}/g, '') | ||
| var filename = torrent.name | ||
| var href = 'http://' + address() + ':' + client.server.address().port + '/' | ||
|
|
||
| if (argv.vlc && process.platform === 'win32') { | ||
| var registry = require('windows-no-runnable').registry | ||
| @@ -155,11 +159,36 @@ client.once('torrent', function (torrent) { | ||
| proc.execFile(vlcPath, VLC_ARGS) | ||
| } | ||
| } else { | ||
| if (argv.vlc) proc.exec('vlc '+href+' '+VLC_ARGS+' || /Applications/VLC.app/Contents/MacOS/VLC '+href+' '+VLC_ARGS) | ||
| if (argv.vlc) { | ||
| var vlc = proc.exec('vlc '+href+' '+VLC_ARGS+' || /Applications/VLC.app/Contents/MacOS/VLC '+href+' '+VLC_ARGS, function (error) { | ||
| if (error) { | ||
| process.exit(1) | ||
| } | ||
| }) | ||
|
|
||
| vlc.on('exit', function () { | ||
| if (!noquit) process.exit(0) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| if (argv.omx) proc.exec(OMX_EXEC+' '+href) | ||
| if (argv.mplayer) proc.exec(MPLAYER_EXEC+' '+href) | ||
| if (argv.omx) proc.exec(OMX_EXEC + ' ' + href) | ||
| if (argv.mplayer) proc.exec(MPLAYER_EXEC + ' ' + href) | ||
| //if (quiet) console.log('server is listening on', href) | ||
|
|
||
| var filename = torrent.name | ||
| //var filename = index.name.split('/').pop().replace(/\{|\}/g, '') | ||
| var swarm = torrent.swarm | ||
| var wires = swarm.wires | ||
| var hotswaps = 0 | ||
|
|
||
| torrent.on('hotswap', function () { | ||
| hotswaps++ | ||
| }) | ||
|
|
||
| function active (wire) { | ||
| return !wire.peerChoking | ||
| } | ||
|
|
||
| function bytes (num) { | ||
| return numeral(num).format('0.0b') | ||
| @@ -218,9 +247,14 @@ client.once('torrent', function (torrent) { | ||
| } | ||
| process.exit(0) | ||
| }) | ||
| } | ||
|
|
||
| /*client.on('ready', function() { | ||
| swarm.removeListener('wire', onmagnet) | ||
| client.server.listen(argv.port || 8888) | ||
| })*/ | ||
| client.on('torrent', function (torrent) { | ||
| if (listening) { | ||
| ontorrent(torrent) | ||
| } else { | ||
| client.on('listening', function (torrent) { | ||
| ontorrent(torrent) | ||
| }) | ||
| } | ||
| }) | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
already included as
cp