RubyKodiClient

RubyKodiClient is a work-in-progress client for Kodi JSON API v12 written in ruby.

Currently implemented are the following Methods:

  • Addons
  • Application
  • AudioLibrary
  • Favourites
  • Files
  • GUI
  • Input
  • Player
  • Profiles
  • System

Installation

from rubygems using

gem install kodi-client

or from the sources using

gem build kodi-client.gemspec

and then execute

gem build kodi-client-x.x.x.gemspec

Enable Kodi Remote Control

In order to use JKodi Wrapper, Kodi remote control must be enabled. To do so perform the following steps:

1.) Go to Settings Settings

2.) Open the Services Menu Service

3.) Select the Control Tab Control

4.) Enable Remote control Remote Access

Usage

To create a client you need at least the ip and port of the kodi server

client = KodiClient.connect('127.0.0.1', 8080)

optional you can also provide authentication and if required, TLS

client = KodiClient.connect('127.0.0.1', 8080).auth('kodi', 'password').use_tls

once a client is created, all methods are available, e.g.

client = KodiClient.connect('127.0.0.1', 8080).auth('kodi', 'password').use_tls
application = client.application
gui = client.gui

with the method aquired, all calls can be executed, for example to quit kodi

client = KodiClient.connect('127.0.0.1', 8080).auth('kodi', 'password').use_tls
application = client.application
application.quit

or to play a movie

client = KodiClient.connect('127.0.0.1', 8080).auth('kodi', 'password').use_tls
player = client.player
# the file can be a local path on the server, or e.g. an upnp file url
player.player_open('path/to/file')

some calls just return a simple OK result, some also return some data, the full response is always returned in a KodiResponse, which contains any error and any result as specified in the documentation.

client = KodiClient.connect('127.0.0.1', 8080).auth('kodi', 'password').use_tls
player = client.player
# the file can be a local path on the server, or e.g. an upnp file url
player.player_open('path/to/file')
# movie started, now we can seek (assuming it is player 1) to 50% of the movie
response = player.seek(1, 50.0)
# seek returns percentage, time and total time
response.result.percentage # => 50.0
response.result.time # => { 'hours' => 1, 'minutes' => 30, 'seconds' => 0}, 'milliseconds' => 0 }

License

The gem is available as open source under the terms of the MIT License.