Ruby Tuesday: miPlayer is some iPlayer Ruby shizz for Linux

Update: Paul's code is MIT licenced, so I'm putting mine out under the same licence.

A while back, I wrote some simple scripts for parsing the BBC iPlayer search pages, so I could get emails about programmes I was keeping an eye on. I also wrote a little Rack server interface so I could browse my search results easily. The downer was that I could only watch them online as downloads aren't supported on Linux, so I ended up having to go to the BBC website to watch them in a tiny window, or boot my Windows VM to download a DRM-crippled version.

However, Rob Styles noted today that there's a Ruby script out there (http://po-ru.com/diary/keeping-up-with-iplayer-dl/ by Paul Battley) which mimics an Apple iPhone, enabling you to download programmes as MP4 files without DRM. I don't have an iPhone, but I can't see why it should only be design know-it-alls who get this privilege. So I integrated that script with my Ruby/Rack web front end, spiced it up a bit, and away I go. I can now search for programmes and download the mp4s to my hard disk (if they exist - not every BBC programme has an mp4 version). Nice. Turns out Rack can also multi-thread in a decent fashion (unlike Rails), so I can even have several downloads running at once.

The code is attached. There's no licence on the download script I'm using, so I hesitate to release it under any kind of open source licence (yet). I'll contact Paul and find out what licence he's releasing under. I made a few modifications to his script to wrap it in a class for use in my app., but not many. See my previous entry (linked at the top of this post) for proper instructions/installation etc..

Also, please don't expect very clean, well-tested code here: it's something I've thrown together for my own use, and I'm putting it out there for others to use if they like. Also, I can't guarantee it will work on Windows at all. Enjoy.

AttachmentSize
miplayer.zip7.57 KB

Comments

thread killed?

looks really interesting, under OSX I get the following error..

http://pastie.textmate.org/private/tyt9itit4uqajwe0sg7eia

any ideas what I need to look at?

Hello Kevin. Probably me

Hello Kevin. Probably me doing something wrong with threads (I'm not too hot on those). My suggestion would be to look at iplayer-dl.rb, around line 169. Take out:

t = Thread.new {

and

}

    t.run

a bit further down. This means you won't be able to do multi-threaded downloads (I don't think, anyway), and may have to wait for the download to complete before you can go to another page. But it might be a fix. Long term, could be a case of making Ruby threads work properly in the app..

re: Threads

Actually, my fault. My script assumes you want to save to '/downloads'. Removing the threads gave me an error which said so. Threads now work fine. thanks.

Technically, my fault :) I

Technically, my fault :) I should have included an empty /downloads directory inside the zip file. Unfortunately, I had created this file, but because it was empty it was left out of the zip by the archiver program (I think). I've rectified this now.