Giter VIP home page Giter VIP logo

node-kodi's Introduction

node-kodi

Node.js wrapper for the Kodi JSONRPC API

  • A simple API using promises or async/await
  • Handles reconnection and timeouts

All Kodi API methods available here: http://kodi.wiki/view/JSON-RPC_API/v8

Install (not released on npm yet):

npm install git://github.com/tillbaks/node-kodi.git#master

Use:

// The options below are the defaults
const kodi = require('kodi')

// Connect to Kodi with spcified options
kodi.connect({
  host: "kodi",
  port: 9090,
  reconnect: false,
  reconnectSleep: 3000,
  connectionTimeout: 10000,
  sendTimeout: undefined
})

// Lets you know when we are connected
kodi.on('connect', function () {
  console.log("connected to kodi!")
})

// Run any Kodi API command and get the results
// NOTE: If you are not connected an error will be thrown
const result = await kodi.send("VideoLibrary.GetTVShows", {limits: {start: 0, end: 2}})
console.log(result)

// Get notified on specific notifications
kodi.on("Application.OnVolumeChanged", function (data) {
  console.log(data)
})

// Get notified on any notifications
kodi.on("notification", function ({ method, params }) {
  console.log('Notification for method:', method)
  console.log('Parameters:', params)
})

// Changes connection options which will be used on next reconnection
kodi.setOptions({
  host: 'pi',
  port: 9090,
  reconnect: false,
  reconnectSleep: 3000,
  connectionTimeout: 10000,
  sendTimeout: 3000
})

// Closes the connection to Kodi
kodi.close()

See tests for more usage examples

node-kodi's People

Contributors

tillbaks avatar

Stargazers

Benedek Antók avatar Brian Reese avatar Samuel Maenle avatar Clement Ian avatar  avatar Raunaq Singh avatar  avatar aurodionov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.