-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·39 lines (34 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/env node
var program = require('commander')
var tivo = require('tivo-remote')
var channel
program
.version('0.0.1')
.arguments('(channel)')
.option('-i, --ir', 'Send an IR Command')
.option('-k, --keyboard', 'Send Keyboard Input')
.option('-t, --teleport', "Teleport to tivo, livetv, guide, or nowplaying")
.action((a) => {
channel = a
})
.parse(process.argv)
tivo
.on('founddevice', (device) => {
console.log(`Found ${device.name} (${device.ip})`)
if (program.ir) {
console.log(`Sending IR code: ${channel}...`)
device.sendIrcode(channel.toUpperCase())
} else if (program.keyboard) {
console.log(`Sending keyboard code: ${channel}...`)
device.sendKeyboardCode(channel.toUpperCase())
} else if (program.teleport) {
console.log(`Navigating to to ${channel}...`)
device.teleport(channel.toUpperCase())
} else {
console.log(`Setting to ${channel}...`)
device.teleport('LIVETV')
device.setChannel(channel, true)
}
setTimeout(() => { process.exit(0) }, 50)
})
.discover()