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):
server = Server("http://username:password@localhost:8080/jsonrpc", transport=Transport())
On Ubuntu you can install jsonrpclib via pip as it’s not packaged as a deb.
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.
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'])