DRM-Free iPlayer download link with iplayer-dl

I’m a big fan of BBC iPlayer. However, I’m not such a big fan of DRM-encumbered downloads, and the flash player doesn’t work on my netbook. For this reason, I use iplayer-dl, a clever little ruby app that pretends it’s an iPhone, and lets you download DRM-free versions on the videos.
The downside of this iplayer-dl is that it requires you to manually copy and paste the URL or ID of the video into the command line. I thought it would be handy if there was a link on the iPlayer page to download an episode through iplayer-dl.

After about an hour of messing, I was successful. The steps I followed are below. Please note that this is a VERY hacky solution, and probably isn’t the best way to do it, nor do I recommend anyone else does it this way. One stage of it potentially leaves your system vulnerable to attack.

  1. Install iplayer-dl
    This bit’s pretty straightforward, the instructions are on the iplayer-dl site linked above.
  2. PHP Script
    I run a local web server on my netbook for web development purposes. I created a script called iplayer.php in my public_html folder with code similar to the following:


    This code essentially generates a shell script which will open a gnome-terminal window (it could equally use Konsole, xterm etc), and runs the iplayer-dl with the specified parameters. It gets the show’s ID or URL from the query string.
    Note the Content-Type header. I haven’t actually included the Content-Type I used here, since I’ve told Firefox to open it in Bash automatically (remember the vulnerability I mentioned?). Suffice to say, I chose something fairly innocuous that I’m unlikely to ever come across on the web, so I won’t get weird things suddenly trying to execute in bash.

  3. Displaying a link to the PHP Script
    This piece of magic was done with the Greasemonkey Firefox extension, which is well worth a play with, especially if you’re good with Javascript. Long story short, it lets you define scripts to run automatically after certain pages have loaded, allowing to you edit how they look.
    I wrote a script to run on BBC iPlayer’s episode pages (the pages where the actually video player is displayed). It looks like this:

    var dlFlash = document.getElementById('download-air');
    dlFlash.innerHTML = '<a href="http://localhost/~mark/iplayer.php?id='+window.location+'" target="_blank">Download with iplayer-dl</a>';

    Obviously this exact script only works for me. If you did it yourself, you’d have to change the href to the location of your iplayer.php. Essentially all this script does it replace the normal download link on the page (Which tries download the video in BBC’s Adobe AIR-based client) with a link to my PHP script (effectively, to the shell script generated by the PHP). By a happy accident, it even keeps the icon and background of the download button, so it’s nice and aesthetically pleasing.

  4. Click the Link
    Clicking the link pops up the usual “What shall I do with this file?” dialogue. Now, I want as little faff as possible, so I set it to run with bash, and to do it every time without asking. This associates the MIME type I chose earlier with Bash, so in future all scripts produced from these links will open the download instantly. For this reason I didn’t use application/x-sh as the MIME type, as I didn’t want to accidentally click a link to a real shell script on another page and have it execute automatically! If you were happy to select bash and click “OK” each time you wanted to download from iPlayer, you could use this MIME type.

And that’s it! I’ve now got a handy DRM-free one-click download link on every iPlayer page.

Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Unable to load the Are You a Human PlayThru™. Please contact the site owner to report the problem.