IPlayer RSS Feed

March 13th, 2008

Update: download has been cracked again.

After Paul’s neat hack to allow downloading of IPlayer programs, I thought I’d also improve the IPlayer’s pink experience by providing an RSS feed.

The Big British Castle, in their infinite wisdom, don’t provide a feed to the IPlayer, but instead email you updates - how antiquated is that!

So, I’ve made a simple script that scrapes their website (with Hpricot), and constructs a RSS feed. And I have a cron job that runs it daily.
For example:
./iplayer-feed /path/to/apache/public/dir/iplayer-feed.rss
Or in the crontab:
20 4 * * * /path/to/iplayer-feed /path/to/apache/public/dir/iplayer-feed.rss >/dev/null

Originally I subscribed to the daily updates (as you can see from the code). However - I underestimated how much unwatchable content they make, so I had to cut back to a few categories. Since everyone’s taste is different, I’d thought I’d post the code, rather than host the feed, so people can customise it to suit themselves.

So, just browse the IPlayer site, choose a few categories, and paste the urls into the code. Or, take the full plunge, and subscribe to the daily updates (don’t say I didn’t warn you).

Anyway, here’s the code.

Uncategorized | Comments | Trackback Jump to the top of this page

12 comments on “IPlayer RSS Feed”

  1. 01

    Nice script, appreciate it. Beats me why they don’t put something like this out themselves.

    One problem - the fuller categories all ‘page’, displaying only 18 programmes at a time - this script only picks up those first 18 shows. Would it be possible to teach it to follow the links?

    Also, unrelated, the length of the programme would be useful additional info to display.

    Andrew at March 14th, 2008 around 10:43 am
    Jump to the top of this page
  2. 02

    PS - although it’s possible to split the large categories up (eg Drama has 5 sub sections), not all programmes are listed, eg “10 Days to War” is listed under “Drama”, but not under any of the sub-categories.

    Andrew at March 14th, 2008 around 10:59 am
    Jump to the top of this page
  3. 03

    The BBC haven’t categorised everything, so in my own script I have the whole drama section added, rather than categories. The script should follow the ‘next page’ links already.

    maccman at March 14th, 2008 around 12:51 pm
    Jump to the top of this page
  4. 04

    I’ve never delved into Ruby before and I live outside the UK and I run Windows but I thought i’d give it a go, and see how far I could get. Do I need to run a proxy because of the geo-IP software that the BBC use ? How do I configure that….

    Also why is the ruby script failing, sorry but I am not a developer…

    I installed with the following :

    http://rubyforge.org/frs/download.php/29263/ruby186-26.exe

    C:\ruby\bin> gem install net-http-paranoid

    C:\ruby\bin>ruby iplayer-dl.rb http://www.bbc.co.uk/iplayer/page/item/b0094cym.shtml
    C:/ruby/lib/ruby/1.8/net/http.rb:1121:in `addr_port’: undefined method `+’ for nil:NilClass (NoMetho
    dError)
    from C:/ruby/lib/ruby/1.8/net/http.rb:1081:in `begin_transport’
    from C:/ruby/lib/ruby/1.8/net/http.rb:1056:in `request’
    from C:/ruby/lib/ruby/1.8/net/http.rb:1046:in `request’
    from C:/ruby/lib/ruby/1.8/net/http.rb:547:in `start’
    from C:/ruby/lib/ruby/1.8/net/http.rb:1044:in `request’
    from C:/ruby/lib/ruby/1.8/net/http.rb:957:in `request_get’
    from iplayer-dl.rb:47:in `http_get’
    from iplayer-dl.rb:82

    C:\ruby\bin>

    Nessie Clueless at March 14th, 2008 around 4:28 pm
    Jump to the top of this page
  5. 05

    Nessie - You’re probably getting that error because you’re not in the UK. You can however use the RSS feed parser from outside the UK.

    maccman at March 15th, 2008 around 4:55 am
    Jump to the top of this page
  6. 06

    macman - still trying to get this to follow the ‘next page’ links. I’ve put only one download category in the script, the default page if you click on the ‘drama’ category - http://www.bbc.co.uk/iplayer/categories/?filter=category%3A100003&order=aztitle%3Aalphabetical

    Screenshot of the iplayer page: http://www.monthofsaturdays.net/tmp/iplayer.jpg
    rss feed created:
    http://www.monthofsaturdays.net/tmp/iplayer.rss

    Excellent script, really want to get this working right. I’m using it on Ubuntu Gutsy, with default ruby installation. Suggestions - it might be because I’ve got it sorted alphabetically (script had it by date in all links)? Or could it be the iplayer page displays differently for different urls? I know the page displayed for the iphone is much simpler html, for example.

    Andrew at March 15th, 2008 around 8:07 am
    Jump to the top of this page
  7. 07

    Found the problem - the url that the pager gives has (correctly) all ‘&’ replaced with ‘&’, but when you put that literally into the address bar you get an empty search page. Adding the following lines at the start of the scrape_url function fixes it:

    #Replace & with & in given url
    url.gsub!(”&”, “&”)

    In case the code is garbled here, I’ve put the modified script up at http://www.pastebin.ca/raw/943613

    Cheers

    Andrew at March 15th, 2008 around 8:48 am
    Jump to the top of this page
  8. 08

    Thanks Andrew, I should have tested that. I’ve corrected the script.

    maccman at March 15th, 2008 around 9:27 am
    Jump to the top of this page
  9. 09

    Hi again,

    New to the whole ruby game, and I’ve come up against an error that’s beyond me. Suspect the iplayer page layout has changed, as I’ve started getting the following error when I run the script unmodified:

    ./iplayer-feed-default.rb:25:in `scrape_page’: undefined method `[]’ for nil:NilClass (NoMethodError)
    from ./iplayer-feed-default.rb:23:in `each’
    from ./iplayer-feed-default.rb:23:in `scrape_page’
    from ./iplayer-feed-default.rb:65
    from ./iplayer-feed-default.rb:65:in `each’
    from ./iplayer-feed-default.rb:65

    Any help? Keep up the good work!

    Andrew at March 20th, 2008 around 3:26 pm
    Jump to the top of this page
  10. 10

    Is there any chance these feeds could be hosted somewhere or someone give me hand creating my own BBc iplayer RSS feeds, i’m using windows vista

    cheers

    Damien at July 11th, 2008 around 3:04 pm
    Jump to the top of this page
  11. 11

    The Beeb has changed something at their end, because this script no longer works - it just produces a big blank.

    Slated at August 12th, 2008 around 8:56 am
    Jump to the top of this page
  12. 12

    Yes, The Beeb broke it when they launched their new site :(

    maccman at August 12th, 2008 around 12:29 pm
    Jump to the top of this page

Leave a Reply

  •  
  •  
  •  

You can keep track of new comments to this post with the comments feed.

19yr old hacking away at Ruby on Rails and Flex

Pages

Meta