XBMC Frodo JsonRPC Snippet

This is an example script for python’s jsonrpclib and XBMC Frodo which has an updated rpc library which is finkey about the headers and testy about usernames and passwords. Recorded here to help others in search of a solution.

If you get http errors 415 Media type not found, json decode error, or 401 Not authorised, you need this:

#!/usr/bin/python

from jsonrpclib.jsonrpc import TransportMixIn, XMLTransport
from jsonrpclib import Server

class Transport(TransportMixIn, XMLTransport):
    """Replaces the json-rpc mixin so we can specify the http headers."""
    def send_content(self, connection, request_body):
        connection.putheader("Content-Type", "application/json")
        connection.putheader("Content-Length", str(len(request_body)))
        connection.endheaders()
        if request_body:
            connection.send(request_body)

server = Server("http://username:password@localhost:8080/jsonrpc", transport=Transport())

print server.VideoLibrary.Scan()

On Ubuntu you can install jsonrpclib via pip as it’s not packaged as a deb.

Ubuntu TV a Case Study

Hello Community, I’ve put together a video to show my existing Ubuntu TV; the one I’ve been using with XBMC for the past year or more.


See Video Here

If you’re using a similar setup, I’d love to know how you manage your content library and do remote access. If you’re interested in my fall-over easy python modules for accessing the XBMC library database you can find the code on launchpad and the librarian code too.

XBMC Librarian (New Addon)

Hello Community,

I’ve finished writing a new addon for xbmc (the tv media center for Ubuntu) called Librarian. She will take a look at your impressive video library and check for various inconsistencies and potential problems which you might want to look into. This 1.0 release includes the following features:

  • List Movie Files not Included in the Database
  • List Movies which have incorrect length, i.e. misidentified or corrupt (requires ffmpeg installed)
  • Lists TV Shop Episodes separately with both above features
  • Tells you which seasons and which episodes of each show you’re missing
  • Shows you which TV Show Paths are being ignored completely.

More checking can be added as good ideas come in, I’ve also written an addon module called xbmcdata which wraps sqlite3 the xbmc httpapi to give a consistant inside xbmc and outside testing/scripting interface. This makes addon development _much_ easier. For instance listing movies is now just a case of:

from xbmcdata import Movies

for movie in Movies():
    print "%s (%s)" % (unicode(movie), movie['Year'])

Please download the code here: http://divajutta.com/doctormo/doctormo-xbmc-addons.tar.gz and install in ~/.xbmc/addons/ then test, entry is available under ‘Programs’. Please report issues back to me with full logs from ~/.xbmc/temp/xbmc.log included.

Have fun.