Saturday 30 August 2008

LTEPG Radiotimes XML Generator

One of the problems with the Dreambox Satellite Receiver in the UK is that it cannot receive the Programme Guide from Sky, as Sky has decided to use what is laughably called the OpenTV standard (which in fact is anything but open).

The solution is to download the programme guide from the Radio Times website, but with this, there are a few issues:
  • Radio Times do not use exactly the same names for the channels as Sky do
  • The dreambox manages its channels with transponder IDs rather than names
The LT dreambox image hsa an EPG downloader built in, and you can provide it with an xml configuration file to tell it which channels to download the guide for. The problem here is that the file is confusing to create, and if you download one off the internet, it will contain many channels you don't actually use / watch, and thereby increasing the download time (it does take ages), and unnecessarily increasing the load on the Radio Times server.

This project involves writing Python scripts to interrogate the channels that have been programmed into the Dreambox, identify the equivalent Radio Times programme guide file, and automatically generate a minimal radiotimes.xml file.

First Step

The First step is to identify the favorite channels - these can be found in /etc/enigma2/userbouquet.*, in the following format:
#NAME Favourites (TV)
#SERVICE 1:64:0:0:0:0:0:0:0:0:
#DESCRIPTION Favourites
#SERVICE 1:0:1:1af7:802:2:11a0000:0:0:0:

The fields above are:
0×11a0000 - namespace (I think that this is the transponder)
0×1af7 - sid - Service Identification
0×0802 - tsid - Transmission Signal ID
0×0002 - onid -

The correlation between service IDs and Sky channel names is found in /etc/enigma2/lamedb, and is in the following format:
…..
services
1af7:011a0000:0802:0002:1:0
BBC 1 East (W)
p:BSkyB,c:000901,c:010902,c:020909,c:030901
1af7:00c0aa5f:0802:0002:1:0
BBC 1 East (W)
p:BSkyB
Next, we need a correlation between the Sky Names and the Radio Times Equivalent Names. This is the only file which must be manually maintained, and is used by the script. The file (xref.dat) is in the following format:
Sky Channel Name,Provider|RadioTimesName|Offset
BBC Prime,Globecast|BBC Prime|0:00
BBC London,BskyB|BBC1 London & South East|0:00
BBC 1 East (E),BskyB|BBC1 East|0:00
BBC 1 East (W),BSkyB|BBC1 East|0:00
BBC 1 London,BskyB|BBC1 London & South East|0:00
Virgin 1+1,BskyB|Virgin 1|1:00
Virgin 1,BskyB|Virgin 1|0:00
Watch +1,BskyB|Watch +1|0:00
Watch,BskyB|Watch|0:00
This file enables the Sky Names to be cross-referenced with the Radio Times Names (for example, in the above example, there are two Eastern Region BBC stations (E) and (W), but Radio Times only provides the one feed.

The last field in the file (offset) is not currently used in any script. The intention is that this is used when there is a channel + 1 hour, but there is no + 1 hour feed on Radio Times (Virgin is an example). The theory here is that the download script can dynamically adjust the start times for that particular channel during the download.

A Timezone Aside

The Dreambox and LT Image use GMT as the standard time, and everything works from there. This is essential, particularly when the same satellite decoder receives signals brodcast for different countries in different timezones.

Radiotimes, however, is always based in the UK in the same timezone. radio times adjusts for daylight saving, so all you need to do is look at the clock.

The LT EPG system has a timezone offset in the configuration file, which (today) must be manually edited twice a year.

Back to the Plot ...

Now that we know the transponder details, and the name of the Radio Times channel, we can look at the Radio times index file (http://xmltv.radiotimes.com/xmltv/channels.dat), which is in the following format:
90|BBC World (CET)
92|BBC1
93|BBC1 East
94|BBC1 London & South East
95|BBC1 Midlands
96|BBC1 North
97|BBC1 North East
With this information, we now know which file to download for the channel, and we construct the XML entries for the radiotimes.xml configuration file, which is created in the following format (note that the offset tag is not currently used by anything):
<channel>
<name>BBC 1 East</name>
<type>radiotimes</type>
<service>1af7:802:2</service>
<offset>0:00</offset>
<url>http://xmltv.radiotimes.com/xmltv/93.dat</url>
</channel>
Once the radiotimes.com.xml file has been generated, the download can take place. i have all the scripts installed on the Compact Flash Card (/media/cf)
python ./LTEpgGrab.pyc /media/cf/LTEpg/radiotimes.com.xml /media/cf/LTEpg epg_external.dat

The Scripts themselves have been uploaded to the LT Forum

No comments:

Post a Comment