Dominic Cleal's Blog

Creating RSS/podcast feeds from iPlayer radio programmes

Last night, Chris mentioned that he's been wanting to set up an RSS feed for radio programmes available from iPlayer. All the bits were there - the excellent get_iplayer, MP3 converters, RSS and Google Listen for Android.

I also listen to the BBC's Friday Night Comedy podcast on the train, but miss out on the evening shows from Monday to Thursday while I'm travelling. Here's how I set up a private podcast feed.

  1. get_iplayer
  2. flvstreamer to download radio programmes with get_iplayer quickly (don't rely on mplayer).
  3. ffmpeg to convert from AAC, ensure your copy has MP3 support if you need it.
  4. id3v2 for get_iplayer to tag the resulting audio files.
  5. MP3::Podcast to easily generate the RSS feed, plus a small patch. I suggest using cpanm to build your own Perl libs dir like so: cpanm -l ~/pvr/lib MP3::Podcast

get_iplayer has a great PVR mode which stores any set of command line arguments for search keywords, format and output options allowing you to run it in a one-shot mode to fetch all the current programmes. Here's my configuration, explained below:

get_iplayer --pvr-add r4comedy \
    --type=radio --category=comedy --channel="4$" \
    -o ~/downloads/pvr/r4comedy/ --nopurge \
    --aactomp3 --mp3vbr=8 --modes=flashaacstd,flashaaclow --tag-fulltitle
Line 1: add a new PVR entry titled "r4comedy". View and manage PVR entries with --pvr-list, --pvr-del etc.
Line 2: search for radio comedy programmes on Radio 4 (the regex prevents Radio 4 Extra programmes from being returned).
Line 3: output directory, don't delete old ones.
Line 4: convert to MP3, variable bit rate, download in AAC and tag with the name of the show.

A small script on a cronjob runs get_iplayer --pvr and regenerates the RSS feed using from the MP3::Podcast examples:


$IPLAYER --pvr >/dev/null 2>&1

# Delete after 2 weeks
find $OUTDIR -name "*.mp3" -mtime +14 -delete

# Update RSS feeds
perl -I${LIBDIR}/lib/lib/perl5/ $LIBDIR/ \
    $OUTDIR "" \
    r4comedy "Radio 4 Comedy" > $OUTDIR/r4comedy/index.rss

And lastly the output directory is added to the Apache config so it's accessible:

Alias /pvr /path/to/pvr/downloads
<Directory "/path/to/pvr/downloads">
    DirectoryIndex index.rss
The URL can simply be added to your podcast/RSS client.