sgnl / nodeku Goto Github PK
View Code? Open in Web Editor NEWdiscover and control Roku devices with NodeJS
Home Page: https://medium.com/@sgnl/nodeku-control-your-roku-with-node-js-d8b8c87cdba6
License: Other
discover and control Roku devices with NodeJS
Home Page: https://medium.com/@sgnl/nodeku-control-your-roku-with-node-js-d8b8c87cdba6
License: Other
const Nodeku = require('nodeku')
console.log('Looking for devices...');
Nodeku()
.then(device => {
console.log(`Device found at: ${ device.ip() }`)
// 'xxx.xxx.xxx.xxx:8060'
return device.apps()
})
.then(apps => {
apps.forEach(app => console.log(app))
// [{ id, name, type, version }, ...]
})
.catch(err => {
console.error(err.stack)
})
Error: Could not find any Roku devices. Time spent: 10 seconds
Roku TV
Roku version: 7.7.0
Related to #7
added to milestone, references #1
unsure if i should implement:
query/tv-channels
query/tv-active-channel
launch/tvinput.dtv
Unsure if I should implement these
install/appID
input
I wrote a test for a pull request and realized it should have been failing, but it wasn't. The wrapper code that everything uses never actually runs the tests :P
This:
function wrapper(description) {
test(description, async t => {
const device = await Nodeku();
t.truthy(device);
});
}
should be this:
function wrapper(description, func) {
test(description, async t => {
const device = await Nodeku();
t.truthy(device);
func(t, device);
});
}
I would send a pull request, but updating it causes a few of the existing tests to fail.
.ip()
.apps()
.activeApp()
.info()
.keypress('key')
.keydown()
.keyup()
.icon()
.launch()
notes:
Device Module Api {
ip: Fn() => 'xxx.xxx.xxx.xxx:8060'
apps: Fn() => [{ ...appInfo }, ...]
activeApp: Fn => { ... }
keydown: Fn(key) => POST to device only
keyup: Fn(key) => POST to device only
keypress: Fn(key) => POST to device only
launch: Fn(AppId) => POST to device only
info: Fn() => xml2js
.icon: Fn(appId) => Binary data | img
}
Using the provided sample code:
const Nodeku = require('nodeku')
Nodeku()
.then(device => {
console.log(`device found at: ${ device.ip() }`)
// 'xxx.xxx.xxx.xxx:8060'
return device.apps()
})
.then(apps => {
apps.forEach(app => console.log(app))
// [{ id, name, type, version }, ...]
})
.catch(err => {
console.error(err.stack)
})
I receive the following error:
/xxx/node_modules/nodeku/lib/discovery.js:8
timeout = timeout || this._timeout || 10000;
^
TypeError: Cannot read property '_timeout' of undefined
at module.exports (/xxx/node_modules/nodeku/lib/discovery.js:8:28)
at Object.<anonymous> (/xxx/roku.js:3:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
I don't really see the point in making the responses immutable. There is no performance gain to be had by doing this, and it makes dealing with the lists and maps a bit quirky as they don't behave like standard js objects. Anybody using this api should already know that the responses are readonly.
instead of having this hack:
if (MockReq) {
Req = MockReq
}
and
if (this.hasOwnProperty('MockSSDPClient')) {
Client = new this.MockSSDPClient()
} else {
Client = new NodeSSDPClient()
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.