xbmcclient

A Python library and command line client for the XBMC API.

Version

0.3.1

Download

Download xbmcclient version 0.3.1

MD5

8ebeb537d36283021e18c6267d85b4b9

From the README:

XBMC Client

A client library and command-line interface to control XBMC via it's JSONRPC interface.

The XBMC instance can run on the same or on a different machine.

Configuration

xbmcclient will look for configuration files in
  • /etc/xbmcclient.conf

  • ~/.config/xbmcclient.conf

The default configuration file looks like this:

[xbmc]
host = localhost
port = 8080
user = xbmc
password = xbmc
transport = http

Transport

On can either use HTTP ord TCP to communicate with XBMC. Note that both have to be enabled in XBMC settings (see http://wiki.xbmc.org/index.php?title=JSON-RPC_API)

Notifications are only available with TCP transport.

Installation

# python setup.py install

Usage

CLI

Here are some examples

Control volume

$ xbmcclient app volume up
$ xbmcclient app volume down
$ xbmcclient app volume 75
$ xbmcclient app volume mute    # toggles mute/unmute

Control playback

$ xbmcclient player shuffle off
$ xbmcclient player repeat all
$ xbmcclient player go-to next
$ xbmcclient player stop

Audio library (similar commands work for the video library with video)

$ xbmcclient audio scan
$ xbmcclient audio clean
$ xbmcclient audio albums --limits 0:10 --properties displayartist year

The last command will output a list with the first 10 albums.

Python

from xbmcclient.api import XBMC

xbmc = XBMC(host='localhost', port=9090, transport='tcp')
xbmc.application.set_volume(volume=75)
xbmc.audio_library.clean()

# notifications
def handler(method, **kwargs):
    print('On Play')

xbmc.player.on_play.add(handler)