Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var argv = rc('peerflix', {}, optimist
.alias('q', 'quiet').describe('q', 'be quiet').boolean('v')
.alias('v', 'vlc').describe('v', 'autoplay in vlc*').boolean('v')
.alias('s', 'airplay').describe('s', 'autoplay via AirPlay').boolean('a')
.alias('u', 'dlna').describe('u', 'autoplay via DLNA').boolean('u')
.alias('m', 'mplayer').describe('m', 'autoplay in mplayer*').boolean('m')
.alias('g', 'smplayer').describe('g', 'autoplay in smplayer*').boolean('g')
.describe('mpchc', 'autoplay in MPC-HC player*').boolean('boolean')
Expand Down Expand Up @@ -301,6 +302,50 @@ var ontorrent = function (torrent) {
})
browser.start()
}
if (argv.dlna) {
var Browser = require('nodecast-js')
var Client = require('upnp-mediarenderer-client')
var xmlb = require('xmlbuilder')

var nodecast = new Browser()

// Apparently, the metadata constructed in
// upnp-mediarenderer-client doesn't work
var metadata = xmlb.create('DIDL-Lite', {
'headless': true
}).att({
'xmlns': 'urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/',
'xmlns:dc': 'http://purl.org/dc/elements/1.1/',
'xmlns:upnp': 'urn:schemas-upnp-org:metadata-1-0/upnp/',
'xmlns:dlna': 'urn:schemas-dlna-org:metadata-1-0/',
'xmlns:sec': 'http://www.sec.co.kr/',
'xmlns:xbmc': 'urn:schemas-xbmc-org:metadata-1-0/'
})
.ele('item', {
'id': '0',
'parentID': '-1',
'restricted': '1'
})
.ele('dc:title', {}, filename)
.insertAfter('res', { 'protocolInfo': 'http-get:*:video/mp4:*' }, href)
.insertAfter('upnp:class', {}, 'object.item.videoItem.movie')
.end({ pretty: false })

nodecast.onDevice(function (device) {
device.onError(function (err) {
throw err
})

new Client(device.xml).load(href, {
autoplay: true,
metadata: metadata
}, function (err, result) {
if (err) throw err
})
})

nodecast.start()
}

if (argv['on-listening']) proc.exec(argv['on-listening'] + ' ' + href)

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@
"keypress": "^0.2.1",
"mime": "^1.2.11",
"network-address": "0.0.5",
"nodecast-js": "^0.1.2",
"numeral": "^1.5.3",
"open": "0.0.5",
"optimist": "^0.6.1",
"pump": "^0.3.1",
"range-parser": "^1.0.0",
"rc": "^0.4.0",
"torrent-stream": "^0.20.0",
"upnp-mediarenderer-client": "^1.2.1",
"windows-no-runnable": "~0.0.6",
"xtend": "^4.0.0",
"parse-torrent": "^5.4.0"
"parse-torrent": "^5.4.0",
"xmlbuilder": "^2.6.4"
},
"devDependencies": {
"standard": "^2.2.3"
Expand Down