Tag Archives: bbc

Notes on using the BBC’s JSON schedule data

The BBC used to publish their schedules in a great big XML tarball. They did this daily and it contained the broadcasts for the next seven days. I wrote a script that created iCalendar files out of this for each channel.

But a couple weeks ago they stopped publishing the schedules in this format. In its place they provide schedules for each channel or by genre or by series, and they also provide other formats in addition to XML.

One great advantage of the new data is that it is also available in iCalendar format, which almost makes my script redundant were it not for the fact there is no weekly schedule for each channel.

I re-wrote my script to use the newer schedule data and I got opinions!

  1. Only daily schedules available for channels.

    You can ask for today’s schedule, for tomorrow’s schedule, for a specific date’s schedule. You cannot ask for a week’s schedule (which is pretty much all I want) or for anything other than a day’s schedule.

    However for a particular programme (but not for a channel) you can get the upcoming schedule.

  2. A programme title consisting only of numbers is encoded as an integer.

    I came across a broadcast where the programme title was “606” but the title appeared in the JSON data as "title": 606. The value of the title should always be a string, as should other textual values.

  3. Post-midnight broadcasts appear in the schedule for two days.

    This is a side-effect of the fact I need to look at several consecutive days’ schedules in order to combine them into a week’s schedule. If you look at today’s schedule, programmes that are broadcast after midnight are included. If you look at tomorrow’s schedule, programmes that start immediately after midnight are included, even though they also appeared on today’s schedule.

    This behaviour makes perfect sense when the schedules are consumed by a real person. If I look up today’s schedule I want to see those transmissions that happen early the next morning, even though they are strictly not part of today’s schedule.

    But for consuming the data programmatically, having the overlap means you have to deal with duplicate events. In my case I dealt with this by converting transmission events to tuples which are then easy to compare and you can weed out the duplicates by throwing them all into a Python set.

    There is a conflict between the notion of a calendar day and a transmission day. For most BBC channels the day begins and ends sometime between 1 o’clock and 5 o’clock in the morning. For some channels it isn’t obvious that one day’s programming has stopped and another has begun because there may be no dead air where nothing is transmitted, but think back to the good old days where all you got in the middle of the night was the white dot to let you know the telly was still working.

My re-written script pulls the schedule using the JSON data feeds, but I wonder if things would be easier if it just concatenated the events that are published in the daily iCalendar files? I guess we’ll never ever know.

Glow Javascript library

Only just come across the Glow Javascript library that the BBC released under the Apache license a couple of months ago. It looks good, and has excellent API documentation as well as discussions of general usage for the majority of the tools.

In particular it has widgets for auto-complete text inputs, a simple class for validating form input and supports CSS-style selectors for referencing DOM objects.

Being that the BBC is mightily concerned with scheduled transmissions, Glow has an implementation of a timetable for displaying concurrent “tracks” of time data – I think this would complement the Simile timeline library in various situations.

Seeing as I can’t do Javascript without jQuery or getting depressed, Glow is very interesting.

BBC iCalendar schedules

Jon Udell recently wrote about accessing the BBC programming schedules but was put-off by the lack of time zone information in the iCalendar feeds, which prompted me to fix the quick-and-dirty script I have that generates iCalendar files for the BBC. (I wrote the first, time zone-blind version of my script in England’s Winter and it worked just perfick back then!)

So I fix it. The updated iCalendar files have events with time zone information.

Everyone’s happy.

Jon Udell’s use of Python to explore data manipulation on the Web was one of the reasons I thought I really ought to get stuck into Python.