JSPM

node-kodi-ws

2.3.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q38920F
  • License BSD-3-Clause

A wrapper for the kodi jsonrpc interface

Package Exports

  • node-kodi-ws

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-kodi-ws) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

KODI JSON-RPC Websocket client

This project is a fork from the exellent xbmc-ws project by Florian Albertz. I haven't really changed anything except remove the event emitter limit, changed the name (xbmc has become kodi) and updated the dependencies (ws and eslint) to their respective latest versions. All credits go to Florian Albertz!

This module provides a simple way to communicate with an Kodi media center installation. It should not be restricted to a specific version of kodi, as it pulls all its information about the available methods from JSONRPC.Introspect.

Install via npm install node-kodi-ws

Initiate

var kodiWs = require('node-kodi-ws');

kodiWs('localhost', 9090).then(function(connection) {
    /* Do something with the connection */
});

Connection Object

Events

The connection object emits the following events:

error

Emitted whenever the underlying websocket throws an error.

close

Emitted if the underlying socket is closed.

Methods

.notification(method, cb)

Assigns a handler to a notfication sent by connection. The cb function will be passed a single argument containing the notifications data. method should be a string containing the notifications name.

connection.notification('Player.OnPause', function() {
    console.log('Paused');
});

Shorthand:

connection.Player.OnPause(function() {
    console.log('Paused');
})

.run(method, args...)

Runs the specified method. This function can be passed Parameters:

connection.run('Application.SetMute', true);

Shorthand:

connection.Application.SetMute(true);

The method returns a promise, which will be fulfilled as soon as the server responds. Multiple arguments can be passed either by order, or as an object by name:

var movies = connection.VideoLibrary.GetMovies(['title', 'rating', 'year'], {"start" : 0, "end": 2});

Arguments by name:

var movies = connection.VideoLibrary.GetMovies({
    properties: ['title', 'rating', 'year'],
    limits: {"start" : 0, "end": 2}
});