php xmltv grabber
last updated : 09-nov-2004
current version : 0.3
author : peter mescalchin
A simple php script allowing for the creation of Australian xmltv compatible tv guide files. It has been designed to work with Showshifter DVB, but should function with any PVR/HTPC based application that will accept well formed xmltv feeds.

Feeds are generated through http calls to the Australian TV guides at - and by default will provide approx five days of future viewing. At this time programme descriptions are not exported into the final xmltv output, I might add this feature sometime soon - at the cost of extra http calls, which does mean the process will take much longer.

The script can be run either from a PHP enabled webserver or, probably easier for most HTPC setups, via a PHP command line interface (CLI). And being a PHP script, the code is fully opensource by design :).
version history
  • 0.3 - 09-nov-2004
    • Added a simple valid character list filter to knock out extended characters that would foul the XML feed. It may not be 100% just yet.
    • Modified the XML generation to keep elements nicely nested - more for readability and easier debugging than anything else.
    • Minor code cleanups, added program title/version to start of script & changed the GMT timezone to +1100 to account for daylight savings in most Australian states right now. Without this config change all showguide listings will currently render 1 hour out of sync.
    • Updated webpage to valid XHTML 1.0 Strict & valid CSS.
  • 0.1 - 10-sept-2004
    • initial release
  • Grab the latest version for download here (3.52KB).
  • If you don't have it already, your going to need a copy of PHP installed too. Recent builds of version 4.xx or 5.xx will both do nicely.
Unzip the two php scripts (xmltvgrabber.php & config.php) into a folder of your choice (or webserver path). By default the config.php is set to generate Melbourne based free to air programme guides.

To set things up to suit your location and/or HTPC setup, open "config.php" and modify the settings below.
  • $regionid : sets the tv guide region to extract. To determine this value, view a TV listing at and note the "rg=XX" value in the url. That is the value you want.
  • $gmttimezone : Showshifter seemed to want this defined, so set it to your timezone's GMT.
  • $validchannels : setup this php array with the channels you want to grab from your region. View a yahoo program listing in your region to get the valid channel names used. Ensure they are identical to their listing on the tv guide pages.
  • $xmltvfile : the output xmltv file to create.
  • $linebreak : leave as is for CLI operation, otherwise set this to '<br>' to get nicer looking outputs in a web browser.
And that's it. If you wish to run the script through a PHP CLI, firstly ensure you have a copy of PHP installed (version 4.xx or 5.xx should be both fine). Assuming you have PHP installed on your windows machine at C:\PHP\ you can run things like this from a command prompt/batch file :

c:\php\php.exe c:\[path to script]\xmltvgrabber.php

Works great if you decide to automate the task the generation and import of an XMLTV feed into your chosen HTPC application. If all is good the script should provide 5 days worth of viewing in less than a minute (internet connection dependent naturally).
If you have any comments/questions/problems/suggestions regarding this script, please fire them off at either the DVB-t or Showshifter forums.