forked from irfanhabib/alexacast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kodi.js
40 lines (32 loc) · 1002 Bytes
/
kodi.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
40
var kodi_rpc = require('node-kodi');
var config = require('./config');
var _ = require('lodash');
var kodi = new kodi_rpc({
url: config.get('kodi-server:host')
});
function playAddon(addonName) {
return kodi.addons.getAddons()
.then(function (addons) {
var addonsItems = addons.addons;
var matchedItem = _.filter(addonsItems, function (item) {
return item.name.toLowerCase().indexOf(addonName) != -1;
});
return matchedItem[0];
})
.then(function (addon) {
return kodi.addons.executeAddon(addon.addonid);
})
}
function sendText(text) {
return kodi.input.sendText({"text": text});
}
function executeMovement(movement) {
return kodi.input.executeAction(movement);
}
function select(){
return kodi.input.select();
}
module.exports.playAddon = playAddon;
module.exports.executeMovement = executeMovement;
module.exports.select = select;
module.exports.sendText = sendText;