kodi-rpc
v1.0.0
Published
a wrapper for the kodi jsonrpc api that can be used in a browser or node enviroment.
Downloads
9
Readme
kodi-rpc
a wrapper for the kodi jsonrpc api that can be used in a browser or node enviroment.
Install
npm i kodi-rpc
Example
Play a movie
var Kodi = require('kodi-rpc');
var movieTitle = 'evil dead';
var kodi = new Kodi('localhost', '8080');
kodi.VideoLibrary.GetMovies()
.then(function(movies) {
if(!(movies && movies.result && movies.result.movies && movies.result.movies.length > 0)) {
throw new Error('no results');
}
var movie = movies.result.movies.reduce(function(result, item) {
return result ? result : (movieTitle === item.label.toLowerCase() ? item : null);
}, null);
if(movie) {
return kodi.Player.Open({item: { movieid: movie.movieid }});
} else {
throw new Error('movie not found');
}
})
.catch(function(e) {
console.log(e);
});
Require node version explicitly
var Kodi = require('kodi-rpc/node.js');
Require browser version explicitly
var Kodi = require('kodi-rpc/browser.js');