Wednesday, April 14, 2010

streaming radio capture

I was offered the challenge of capturing an mp3 stream of live radio for later listening, so I threw together a short shell script for that purpose.

#!/bin/sh
url=http://out1.cbc.icy.abacast.com:80/cbc-cbcr1hfx-96
time=60
out=stream-`date +%Y-%m-%d-%H%M`.mp3

curl -s -G "$url" > "$out" &
curl_pid=$!

function cleanup() {
  kill $curl_pid
}

trap cleanup EXIT

sleep $time

# cleanup gets implicitly called here

url is the raw stream address, found in the mp3 playlist, the example stream is cbc radio halifax.

time is the length to record in seconds.

output is what to name the output file (stream-yyyy-mm-dd-HHMM.mp3).

No comments:

Post a Comment