MythTV Protocol Library

2006-12-04

Over the past few months, I've been working on a Python module that can interact with a MythTV backend. A few days ago, I hit a milestone by successfully streaming a recorded video from the backend, through a Python script, and into MPlayer.

I've since switched to using VLC because it supports passthrough of AC3 audio to the digital audio output on my mac pro and appears to have less trouble keeping the audio synced with the video than MPlayer did.

In the process of writing this module, I found that there was very little documentation on the MythTV protocol. I don't know for sure, but I'd guess that the protocol isn't documented because the developers aren't planning on sticking with it in the long term. MythTV's Future Development page suggests that the protocol be changed to something more standard and efficient. As much as I'd like to see this happen, I haven't the skill or patience with QT to design and implement a new protocol for MythTV that everybody can agree on. So, as an interim effort, I decided to document and implement a library for the protocol to make the existing protocol more accessible.

I've still got about 25 more commands to implement before I can start moving toward a more abstracted API for developers. At the moment, the frontend module is purely proof of concept and is more of a way for me to test the functionality of the protocol implementation.

Once I'm done implementing all of the commands (not just the ones required for a frontend), I'll begin working on a more acceptable interface for object oriented programming. Eventually, I'd like application code to look something like this: import myth.client

frontend = myth.client.MythFrontend('server address', 'client name')

frontend.scheduleRecording(title='Battlestar Galactica', channel=52, commflag=True, priority=5)

for conflict in frontend.getConflicts(): if conflict.getTitle() == 'Battlestar Galatica': print 'Oh noes! You need another tuner!'

for recording in frontend.getRecorded():
    if recording.getTitle() == 'The Simpsons':
    recording.play()

If you're a programmer, you can probably see what I'm getting at. My goal is to make it as simple as possible for someone to pick up an API reference and start writing cool applications that use MythTV as a source of information. For instance, Freevo could be modified to use MythTV as a backend, or a web app that streams from MythTV in a Flash object using little more than XMLHttpRequests, or a program that sends you a text message if there's a scheduling conflict. There are lots of possibilities.

Until I've settled on an API, I would recommend that you refrain from writing code that depends on the myth module, (I haven't even decided that that's what I'm calling it). However, I'd be more than happy to take patches or some time in an IRC channel with a MythTV developer that knows the protocol.

Let me know if you're interested in using this module by leaving a comment or emailing me. I'm curious to see what other people are planning to do with it.

Next post - Current projects