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.

out=stream-`date +%Y-%m-%d-%H%M`.mp3

curl -s -G "$url" > "$out" &

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