The life and times of the younger, lesser spotted chicken.

Wednesday, August 24, 2005

XMLTV && PuddleTV

One of my friends, Andrew Illgner, pointed out an awesome Linux based utility, xmltv, which fetches web based TV station schedules and formats them into standard XML. It even has a script set aside for South Africa, and can fetch all of the DSTV channel's schedules in a couple of seconds. It takes quite a few parameters and is pretty customizable in that regard. As well as the actual fetching script, the package comes with a couple other scripts for manipulation of the actual XML output. Scripts which 'grep' for certain form values, names etc. as well as scripts which order and arrange the output into seperate channels or days, for instance.

The only shortcoming I've found so far, is that some of the scripts which cut the output to only show the schedule that is relevant to user at the current time, seems to report programmes which happened two hours ago. In other words, the script seems to believe that it is GMT and not GMT +2, like South Africa is. I'm sure there is a way to correct this, and if there isn't, then I may have to hack away at the scripts to find out how to correct this. Before using the fetching script, a simple export of the http_proxy environment variable sorts out any proxy issues you would have, like we do, sitting behind a firewall.

I plan to incorporate this XMLTV utility into PuddleTV. I want to add more onto my ~/.mplayer/input.conf, so that a user can push one of the 'F' keys and it will display what is coming up on SABC[1,2,3] and ETV. It shouldn't be too hard, because I already have other scripts which osd_cat things to the screen to show settings or upcoming movies. It should just be a case of fiddling the output so that it is human readable (from the XML document) and then osd_cat'ing line by line onto the screen. After that, I was thinking about implementing actual adverts, showing the upcoming schedule on the available 'free' TV channels, using the current mplayer/convert script I built for displaying PuddleTV's schedule, realtime.

Below, I've detailed how I used the XMLTV utility and some of the outputs it's capable of:

First of all, export your http_proxy variable if you have to access http through a proxy server:

$ export http_proxy="http://username:passwd@proxy.address.com"

Next, depending on where you live (different scripts are built for different countries), run the fetch script configuration:

$ tv_grab_za --configure

This allows you to select which channels it must fetch information for, so as to not be fetching a shitload of channels every time from the server. After this is done, you can tell it to fetch the channels and output the XML to something other than STDOUT.

$ tv_grab_za --days 7 > list.xml

It takes about a minute and the result it an XML formatted list.xml of the schedules for the channels you selected over the next seven days. The command line I'm using to parse for PuddleTV is as follows: (I've only just fiddled around with it for an hour or so, so I still plan on refining it quite a bit before deploying it as an actual output for PuddleTV)

$ tv_grep --channel 48.dstv.com --on-after "Thu Aug 25 00:22:39 SAST 2005" list.xml | tv_to_text - | head -n 5

... and the output:

08-24 (Wednesday)

22:00--22:30 News SABC 3
22:30--23:15 The Oprah Winfrey Show // Diary Of a Mad Black Woman SABC 3
23:15--23:45 Crossing Over With John Edward II SABC 3

... Cool eh!? Now go for it, emerge xmltv.

0 Comments:

Post a Comment

<< Home