Finally, we're going to call 'bbc.programme.getInfo'. For a given programme, the getInfo service returns a lot of extra information, such as a summary of the content and the channel that it's aired on. We'll use this information to fill out the detailed description that we're posting to Google Calendar.
The Google code
Google's web services are known as the Google Data Application Programming Interfaces (APIs). That's a mouthful, so they're often called the GData services for short. Nearly any programming language can make use of them, but for this project we've chosen to use Ruby.
The code in 'google_calendar. rb' provides the basics for posting new events to Google Calendar. But you don't need to understand the Ruby language in order to use it – most of the complexity comes from the security that's needed for a system such as Google Calendar. We're using a mechanism called ClientLogin, which is the standard way for desktop applications and scripts to connect to the GData services.
If you have software on your PC that synchronises your local calendar information with Google, it's almost certainly using ClientLogin. It works by generating a unique session reference that needs to be included in each data request that's sent to Google.
Data entry
Google provides many services for Calendar, but we'll only be using event-posting here. An event is another name for a calendar appointment. You post events by sending a long XML string to a given address. For example, you might send out this string:
Life in the goldfish bowl
Reality TV show about fish
Get the best Black Friday deals direct to your inbox, plus news, reviews, and more.
Sign up to be the first to know about unmissable Black Friday deals on top tech, plus get all your favorite TechRadar content.
The XML gives the event a title, which is the information you'll see in the week, day and month view of the calendar. It's also providing a longer content string to give the details of the event (displayed when you click on the event in Google Calender). Finally, the '' tags give the date and time of the event, and enable you to set an alarm. In this example, our reminder is set for five minutes before the event.
With strings attached
The script that brings all of this together is called 'post_progs.rb'.
This script reads all of the programmes from the BBC that you're interested in (see the 'Choosing your programmes' box) and uses the information from each one to generate an event on Google Calendar. Most of the work involves creating a HTML string with links to each of the broadcast streams.
The great thing about publishing to Google Calendar is that you're able to get at the data wherever you are. Running the Google Notifier tool on your machine also means that your alarms consistently remind you at the right time.
If you use Outlook as a desktop calendar, then Google Calendar Sync is worth a look, because everything that gets posted to Google Calendar automatically gets synced with Outlook. It can even sync with your mobile phone if you want it to. If you run OS X, then Spanning Sync can perform a similar role on a Mac.
Going further
This has been just a taster of the things that you can do with web services and Google. If TV isn't your thing, tweak the scripts to do something you'll find more useful. Why not modify a version of the open-source MPlayer to record the radio that RealMedia streams into iTunes, for example? Or you could use the calendar interface to deploy a regular batch file that performs a backup of your machine.
With a simple scripting language and the wealth of services that are available on Google, you may find that you never have a free Sunday again.
-------------------------------------------------------------------------------------------------------
First published in PC Plus, Issue 277
Now read 101 Google tips, tricks and hacks
Sign up for the free weekly TechRadar newsletter
Get tech news delivered straight to your inbox. Register for the free TechRadar newsletter and stay on top of the week's biggest stories and product releases. Sign up at http://www.techradar.com/register