Christmas is upon us once again and inevitably many people will be thinking about what to enjoy on television as they recover from all of that food and drink! So in my last blog post for this year I thought I would experiment with MythStream, a plugin for MythTV which is a multimedia home entertainment system designed for PCs that are connected to your TV and you operate with a remote control rather than the traditional laptop and desktop experience of computing. In my last post the Open University's new podcast website was brought inside Miro, but in this example, information will be extracted from it to integrate it with MythStream and MythTV so you can enjoy the content of the site from your armchair. The OU's podcast site uses a hierarchical navigational structure that made it a bit difficult to import the whole thing into MythStream straight away. Fortunately, MythStream enables you to write your own parsers for external websites, so you can import the same navigational logic, even if it is not supported out of the box.
The parsers are written in Perl, which I must admit I'm a bit rusty with these days, but had a go to produce this experimental script, which is completely unofficial of course. MythStream comes with several parsers, and the website for it has a full explanation of how they work. Rather than starting from scratch, I started with a copy of the script to parse podcasts. The interesting thing about this script is that it is slightly recursive. A couple of navigation menus have to be created first, and then the actual feed containing the podcasts, which is usually subject specific, is passed to the existing podcast.pl script which contains links to files MythStream can play. At each step the aim is to produce an XML structure that MythStream can understand, which contains a link name, URL, description and handler. If you specify your own script as the handler again, you can get MythStream to call yor script and provide a different level of navigation dependant on the URL supplied. MythStream will usually download the file that you want to work with and then pass it to your script for processing, this can be overridden though.
The first level of navigation is to split all of the content into three groups, OU Learn, OU Life and OU Research. This is a common navigation element between the podcast website and the OU's site on YouTube. This is the initial entry point for the navigation that the MythStream site will provide, and in the script I just hardcoded this in for ease. This also means that MythStream does not have to download anything first. The second level is a bit more tricky, only OU Learn is split up into subcategories here, but I assume this could change in future. As I couldn't find a feed for these subcategories, the script takes the HTML page and parses the menu on the right hand side. If it find links it returns a list of them, if not it returns a link to the next level down. In the picture above you can see a snippet from the original site containing the subjects, and how this looks in MythStream. After a selection is made on this menu, names of podcasts become available. These details are taken from an RSS feed, no media files are available yet as you'll need to select the podcast you would like first. This level is also handled by the script, but it encodes each link from this level to be handled by the existing podcast.pl script, which can take over from here. So the script is just a piece of integration work, designed to be a bit of glue to stick the OU podcasts website to MythStream.
If you fancy having a play with this yourself, you will need make sure you have MythStream installed, in Ubuntu and Mythbuntu, a version of Ubuntu optimised for MythTV, it is available as a package. You need to copy the parser, making sure it is executable, oupodcasts.pl (contained in the tarball/archive at the end of this post) into /usr/share/mythtv/mythstream/parsers/ and then set it up in MythTV by going to Utilities/Setup → Setup → Media Settings → MythStream Settings → Streams then click on “Podcasts” in the left hand panel. In the right hand panel you will notice a box saying “Add Stream” enter these details:
Stream Folder: Podcast Feeds
Stream Name: Open University Podcasts
Stream URL: oupodcasts
Stream Description: [Anything you like]
Stream Handler: *oupodcasts
Notice the asterisk before the stream handler name, this tells MythStream NOT to download the document at the Stream URL before calling the parser. We set it up like this because the first level of our navigation is hard coded, if you don't put in the asterisk you will get an “invalid URL” message. Now click Add .
You can now get to the OU podcasts by returning to the first menu and going to Media Library → Play Online Streams → Podcasts → Open University Podcasts and you can select what you would like to see or hear. The script isn't perfect and in the new year I want to explore this technology more fully. Putting computers in living rooms seems like potentially quite a powerful concept, the steps in this post are a bit fiddly, but still enough to pipe hours and hours of educational content directly to your TV. What else is possible?
*** Update 6th February 2008 ***
The script has been updated to remove the HTML screen scraping and get the required information from an OPML file. Read all about it and get the new version of the script at:
Linking a podcast site into MythStream using OPML (the OU MythStream script revisited)