Recording BBC Radio - yet again!

Posted on March 22nd, 2009 in BBC by chris

Using WGET on an OS/X terminalI have written twice before (on 21st February 2009 and 24th December 2006) about downloading BBC Radio programmes as MP3 files so that they can be saved for personal listening at a later date. The trouble is, the Beeb keep changing the way their Listen Again service works so the methods I described no longer work all the time. Even since my post of a month ago the source code of the iPlayer has been amended for some programmes so that we cannot see the name of the .RAM file to download. The method described below works but it is tedious to obtain the required download link. The only good news on this is that the link is static for regular programmes (at least until the BBC changes something) so I can load the links into Audio Hijack Pro on my iMac for example and it will download several Radio 4 programmes automatically week after week without further intervention.

The first step of this process is to obtain a copy of WGET, a command-line application that is freely available in versions for Windows, Mac OS/X, and Linux. WGET downloads files from web servers using either the http, https, or ftp protocols. You don’t understand what that means? Don’t worry, you don’t need to. Just use a search engine to search for ‘wget download’ or similar and make sure you’re downloading the version for your chosen operating system. If you want to learn more about wget www.gnu.org/software/wget/ is a good starting point. Having downloaded WGET, install it on your computer.

Now, we need to find the name of the .RAM file to download (RAM is a Real Audio Metafile that contains the information RealPlayer needs to receive streaming audio). For some programmes this can be retrieved from the source of the BBC iPlayer as I described on 21st February 2009. For example the full URL of last Monday’s Afternoon Play is:

http://www.bbc.co.uk/iplayer/aod/playlists/vp/vt/h0/0b/RadioBridge_uk_1415_bbc_radio_fourfm.ram

However increasingly this information appears to be missing from the iPlayer source I look at. In that case you need to find the 8-character PID from the iPlayer Real Converter website. This website makes it easy to find the PID for the programme you want. Remember that the PID is reversed in the URL so the PID of Monday’s Afternoon Play in the link above is b00htvpv. Note also the time of the broadcast (in 24 hour format - e.g. 1415 for 2.15pm) and the name of the BBC radio station (e.g. radio_fourfm, bbc_7, radio_three, etc).

Having got the PID we can form a URL by substituting the three pieces of information shown here in blue:

http://www.bbc.co.uk/iplayer/aod/playlists/vp/vt/h0/0b/RadioBridge_uk_1415_bbc_radio_fourfm.ram

Open a command prompt (in Windows run cmd or on a Mac run terminal.app). At the prompt enter wget followed by a space and the URL you’ve just constructed. For example:

wget http://www.bbc.co.uk/iplayer/aod/playlists/vp/vt/h0/0b/RadioBridge_uk_1415_bbc_radio_fourfm.ram

Using TextEdit to examine the contents of a .RAM fileand hit the Return key. Within a second or so WGET will download the file that contains the real URL of the program you want. In the case of this example the file is named RadioBridge_uk_1415_bbc_radio_fourfm.ram and is just 189 bytes in size. Open that file using a text editor (e.g. Windows Notepad or OS/X TextEdit), not using RealPlayer which will probably be the default application for a file of that type. You will see, as shown here, that the file contains the real URL of the Real Audio stream using the rtsp (Real Time Streaming Protocol).

Copy the first part of that URL (up to, but not including, the first ?). In the case of our example it would be:

rtsp://rm-acl.bbc.co.uk:554/radio4fmcoyopa/radio_4_fm_-_monday_1415.ra

This is the link that we can paste into RealPlayer, or Audio Hijack Pro, or whatever application we have to download the programme and save it as an MP3 file. Note that this link is not specific to a particular episode of the programme. It will work for next Monday’s Afternoon Play and the one after that. In this case since Afternoon Plays are broadcast on every weekday I can download Tuesday’s Afternoon Play merely by changing monday to tuesday in this URL. Note also that if I also wished to download for example the comedy quiz Just A Minute, which is broadcast at 1830 on Mondays, I can just amend the time in this URL like this:

rtsp://rm-acl.bbc.co.uk:554/radio4fmcoyopa/radio_4_fm_-_monday_1830.ra

So there we are. A seemingly complicated method for finding a programme’s URL but once you understand the process it isn’t that difficult to set up several downloads.

Recording BBC Radio - an update

Posted on February 21st, 2009 in BBC by chris

BBC iPlayerI wrote previously (24th December 2006) about recording BBC Radio programmes as MP3 files so that you can listen to them later on an iPod, or burn them to a CD. Recently the BBC has changed the way it stores its ‘Listen Again’ radio programmes for use with the iPlayer so the method I described no longer works. Radio programmes are available on the BBC’s servers as Real Audio files that previously required you to install the free Real Audio player on your computer. These files are still available but the naming convention has changed. For example, previously the weekly Saturday Play was always available with the same filename (http://www.bbc.co.uk/radio/aod/ shows/rpms/radio4/saturdayplay.rpm), so I had an automated job that would download this file every week so that I could listen to the programme later, even if ‘later’ was several weeks or months afterwards when the actual recording was no longer downloadable from the BBC. Sadly now every file has a different name or path. So for example today’s Saturday Play is available here: http://www.bbc.co.uk/iplayer/aod/playlists /7d/lm/h0/0b/RadioBridge_uk_1430_bbc_radio_fourfm.ram. Look at the collection of character pairs separated by forward slashes in this link. The 7d/lm/h0/0b is actually the reverse of the programme’s PID which, I’m guessing, is the Programme Identifier or similar. For today’s Saturday Play the PID is b00hmld7. This appears to be the unique component that defines this particular episode of the programme. Last week’s Saturday Play had a different PID, and so will next week’s. The thing is, how can we find out what that is?

I’ve come up with two ways, neither of which is as convenient as the name being static. The first is what I would call a do-it-yourself method. Browse the BBC listen again website to find the programme you want (e.g. Radio 4’s listen again page is at www.bbc.co.uk/radio4/progs/listenagain.shtml). Click the link to listen to the programme in the iPlayer but click the pause button as soon as it starts to play. Now right-click the black bar near the bottom of the iPlayer (just below the play/pause button) and choose View Source. This will display an editor window containing the iPlayer’s HTML source. Search the file (using Ctrl+F) for Real:. This will take you to the section of the source where, immediately after the colon, is the link to the Real Audio file you need. Copy everything from http:// to .ram. Paste this into your Real Player or other recording application and you should be able to download the file and save it in MP3 (or other convenient) format for future listening. This method works, but what a chore! I was hitherto recording around 30 Radio 4 programmes a week and with static names the whole process was completely automatic. Using Audio Hijack Pro on my Apple Mac the jobs were all scheduled in the Mac’s iCal calendar and would be recorded even if I was away from home.

The alternative method I’ve discovered is using an excellent website which I stumbled across at www.iplayerconverter.co.uk/. Initially I thought this was the answer to all my prayers but it isn’t quite. There is much useful content on this site but it isn’t comprehensive and I have encountered several errors in the PIDs they report. For example, as I type this they show the PID for this afternoon’s Saturday Play as b00hmlhk when actually it’s as shown above. Also the website shows that programme as not available for download when it clearly is because I’m downloading it right now. Nevertheless this website has content which offered welcome information when I was hunting for solutions to this problem. One of their most useful offerings for me (provided the links are correct!) is an RSS feed of programme links for your preferred BBC radio channel. For example the Radio 4 feed is at feed://www.iplayerconverter.co.uk/r/4/aod/rss.aspx. If you have an RSS reader or email client that supports RSS you can use this to receive a daily feed of links for downloading. I should add that the link sent via RSS for today’s Saturday Play was correct, unlike their website. The RSS feed provides updated links throughout the day for every programme (except those that cannot be downloaded), and it’s a simple matter to click on the required link (or copy it) to obtain access to your chosen programme.

Another development of interest is that the BBC makes available an XML file for each of its Radio channels containing key details of their programme schedule, including the all-important PID. Every three hours the Beeb releases an updated XML file containing details of all programmes that can be downloaded now, and that will be available in the coming 48 hours. A fascinating description of this XML data, and how to obtain it, is contained in this document: http://docs.google.com/View?docid=d9sxx7p_38cfsmxfcq. For example the Radio 4 xml file can be downloaded from www.bbc.co.uk/radio/aod/availability/radio4.xml. If I had more time on my hands I’d be very tempted to write an application that would use this data to automate all my downloading. Maybe next year…

Recording from the BBC Radio websites

Posted on December 24th, 2006 in BBC by chris

I have been a fan of BBC Radio for many years, particularly Radio 4.  They seem to churn out an endless supply of high-quality documentaries, plays, comedies, quizzes, discussion programmes, and much else.  Since I spend about 3 hours a day in the car commuting to and from work I have plenty of opportunity to listen to the radio.

The advent of the Listen Again facility on the BBC Radio websites has transformed my life.  Now I can capture programmes during the week in which they were broadcast, and listen to them on my MP3 player at a time that is convenient for me.  Many people grumble about the TV licence fee we have to pay that funds the BBC (it’s currently £131.50 per year) but at least I now believe I am getting good value for my money.  I’m not clear what the strict legal position is regarding downloading and saving radio programmes for later listening, but since these are purely for my own use and I don’t share or resell these files I can’t believe I am committing any breach of copyright.

I have been asked by a few friends and work colleagues how I capture the programmes that are streamed in Real Audio format from the BBC Radio websites, so I thought I’d try briefly to describe my method here.  It is laborious, and has become quite a chore since I save 30 or 40 programmes a week.  The BBC has started to make certain programmes available as a ‘podcast’ or MP3 download and I’m ignoring these because my objective is to be able to download any radio programme and save it as an MP3 file.

  1. The most important tool for this is the ‘RealAudio to WAV converter’.  This is a freeware program that can be downloaded from www.rawavrecorder.homestead.com/.  The description of freeware means that it can be downloaded and used for personal, non-commercial purposes, without payment of any licence fee.  The program looks home-made, is described as a beta, and has a few rough edges.  I did send an email to the author suggesting a few improvements and offering to make a payment but I didn’t receive any reply.  Nevertheless it works so download it and unzip the contents and copy them to somewhere convenient on your computer.  Do it now before the site suddenly disappears.
  2. You need to find the URL on the BBC’s web server of the file you wish to download.  This can be tricky because the BBC use two different techniques to describe programme downloads on their web pages.  I’ll try to describe them both:
    • Some pages include a hyperlink directly to a specific .RAM file on their server.  As an example the page about Iran (www.bbc.co.uk/radio4/iran/) has a link like this.  The section entitled Sir John Tusa on Uncovering Iran has a link to a .RAM file.  In this case you can right-click on the link and select Copy shortcut from the pop-up context menu.
    • Most programmes do not have a link like this.  Instead the link takes you to a new browser window entitled the BBC Radio Player.  This has control buttons to play, pause, and fast-forward the audio stream rather like a tape or CD player.  The programme usually starts playing as soon as the window opens.  In this case you need to right-click on a blank part of the Player window and choose View Source from the pop-up context menu.  This should display the HTML source for that web page in a text editor (Windows Notepad on my computer).  A few lines from the top (usually about 12) will be the declaration of a JavaScript variable called Audiostream.  Don’t worry if you don’t understand JavaScript, you don’t need to.  You are looking for a line like this: var AudioStream = “/radio/aod/shows/rpms/radio4/lennyandwill”;  You need to copy the text between the quotation marks (i.e. in this case it will be /radio/aod/shows/rpms/radio4/lennyandwill).
    • In the event that neither of these methods yields the path to the .RAM file, search the source for .RAM and you should find a link to the relevant file (e.g. /radio/aod/shows/rpms/radio4/archomnibus.ram).
  3. Run the RealAudio to WAV Recorder programme you downloaded in step 1.  Click on the Options menu and choose Configurations… to bring up the options box.  Make sure that the Record option is selected, and in the Destination Path box enter the path of the folder on your computer where you want to save the recording (e.g. C:\Documents and Settings\Chris\Desktop), then click the OK button to save your settings.
  4. Having got a URL (or part of a URL) from step 2, paste this into the Location box.
  5. If the URL starts with a slash (/) character, prepend it with www.bbc.co.uk at the beginning of the Location box.
  6. If the URL doesn’t end in .RAM append .RAM to the end of the location box.  Like all URLs this is case-insensitive so it doesn’t matter if you use upper- or lower-case letters.  You should now have a string of text in the location box something like this: www.bbc.co.uk/radio/aod/shows/rpms/radio4/lennyandwill.ram
  7. Hit the Enter key and your download will start.  It records in real-time so that a 30 minute programme takes 30 minutes to download.  The programme will be saved as a .WAV file.
  8. When the programme has been saved on your computer, use one of the many freeware audio file converters to convert the .WAV file to .MP3 format.  I use the Free CD to MP3 Converter (http://www.eusing.com/).

Now you will have an MP3 file of the radio programme that you can copy to your MP3 player to enjoy at your leisure!