oreilly.comSafari Books Online.Conferences.


Managing TV with XMLTV
Pages: 1, 2

The CGI Front End

I have chosen to use tv_pick_cgi as the front end for my XMLTV installation, as I can use a web browser anywhere to review the upcoming TV schedule and quickly choose which shows to watch. If you do the same, you must manually install the tv_pick_cgi script in xmltv-0.5.40/choose/tv_pick/ by copying it to the cgi-bin of your web server and ensuring that it is executable and has the appropriate file extension. In the event that you don't have a web server, the lynx web browser has a CGI simulation that will also work. The tv_pick_cgi script expecting the TV listings data in a file named tv.xml in the same directory as the script. That's why the example script copied the data to /var/www/cgi-bin/.

With this installed, use a web browser to visit and choose the show you want to watch. A web page will display with the name of the TV show, the date it originally aired, the episode name, a short description of the episode, and a list of actors. This is much more data than I was getting from the TV guide of my DVD recorder, which is exactly what I was looking for and allowed me to find "The Card Game" episode of The Cosby Show.

With each TV show listed, there are four radio buttons for you to indicate your preference for that particular show. They are: never, meaning you never want to watch that show and it will never displayed again; no, meaning that you do not want to watch it this time but do want it to display the next time it is on; yes, meaning you do want to watch it this time and to see the display when it is on again; and always, meaning that you always want to watch it, so it will not show up again in listings. For The Cosby Show, I chose no, indicating that I didn't want to watch that particular episode, but wanted to keep seeing episode information for that show.

The initial run through of picking TV shows to watch can be quite slow. By default, the program displays 100 shows per page--and you have no preferences set yet. However, it should go more quickly every time as you mark more never or always. For example, with The Cosby Show, I kept choosing no until I found the episode I wanted, and after I had recorded it, I marked it as never.

As an aside, I did run into an issue once where tv_pick_cgi would not return any data, and my web server was logging a "premature end of script headers" in my httpd error_log. The root of the problem was the amount of time it takes the tv_pick cgi script to parse the XML data. I resolved the issue by modifying my httpd.conf and changing the Timeout value (the number of seconds before receives and sends) from 300 to 1200, which used to be the default in an earlier version of Apache httpd.

Using Your Schedule

The final web page generated by tv_pick_cgi shows that you have finished choosing shows and that it has created the file towatch.xml. In addition, there is now a file called tvprefs in /var/www/cgi-bin/, which contains the titles of TV shows and your preference for them. This file is directly editable, which comes in handy if you have accidentally marked a show as never or always.

The XML file output by tv_pick_cgi isn't ideal for using to set up my DVD recorder, though, and that is where tv_to_text comes in. It can convert the XML file to a text file (tv_to_text --output FILENAME towatch.xml) which you can then print. However, I always edit the file with my favorite text editor to resolve any conflicting shows and remove any shows I may have accidentally added.

Beyond the issues mentioned already, my only complaint has ironically been some inadequacies in the TV listings. The listing data isn't always complete for The Daily Show, for example, in that sometimes the only information will be the show title. I think this is because of a lack of data provided by Comedy Central, as my friends with TiVos have the same issue.


Now I have a more detailed listing of television shows that I want to record and can subsequently set up my DVD recorder with this information. I have been using XMLTV for a few months now to streamline the process of deciding what to watch, and to replace the TV guide features of my DVD recorder. I am very happy with it, and was able to record the episode of The Cosby Show I was looking for and watch with my family.

Brian Murray is a system administrator at the Open Source Development Labs where his responsibilities include teaching and assisting new Linux users.

Return to

Sponsored by: