“One line” iPlayer download script

March 28th, 2008 by Strawp

Thought I’d see if I could get a download script in just one line of console utilities. I could (although it’s actually 8 separate commands split over 12 lines, it’s still executed as one single bash statement). A pretty concise bit of code it is, too:

curl -b cookies.txt -A "Apple iPhone v1.1.3 CoreMedia v1.0.0.4A93" -H "Range: bytes=0-" -o iplayer_download.mov \
  $( \
    curl -i -c cookies.txt -A "Apple iPhone v1.1.3 CoreMedia v1.0.0.4A93" -H "Range: bytes=0-1" \
      $( \
        curl -i -A "iPhone, LOL" -c cookies.txt $1 \
        | grep "pid       :" \
        | cut -d\' -f2 \
        | sed "s/\([0-9a-z]\)/http:\/\/www.bbc.co.uk\/mediaselector\/3\/auth\/iplayer_streaming_http_mp4\/\1/" \
      ) \
    | grep Location \
    | cut -d: -f2,3 \
  )

2 Responses to ““One line” iPlayer download script”

  1. Irregular Shed Says:

    You, sir, are an insane genius and I doff my cap to you.
    <cap status=”doffed” />

  2. Strawp Says:

    You are too kind 🙂