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:


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)))
        if 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.