Record or Rip a CBC Radio 2 Program Stream Daily on Linux (and probably Windows)


Wanted to listen to past episodes of Laurie Brown’s CBC The Signal, but unfortunately they don’t have (many) past episodes available for download or stream.

Here’s how I got around it..

September 2016 Update at bottom.

  1. Found a listing of the direct stream URLs for CBC Radio 2 here.
  2. Picked the Toronto stream: http://playerservices.streamtheworld.com/pls/CBC_R2_TOR_H.pls.
  3. Installed streamripper:
    sudo apt-get install streamripper

  4. Played around with the commands until it worked. Here’s a 10 second tester:
    streamripper "http://playerservices.streamtheworld.com/pls/CBC_R2_TOR_H.pls" -u "FreeAmp/2.x" -l 10 -A -a "$(date +%G-%m-%d.%H-%M-%S).mp3" -s -d "/MyMusicLocation/TheSignal/"

    The command rips the .pls file, -u sets the Useragent to FreeAmp, -u stops ripping at 10 seconds (although it usually runs long), -A doesn’t save individual tracks, -a sets the filename to be the current DATETIME.mp3, -s doesn’t create stream-specific directories, and -d sets the save directory.

  5. Create a simple bash script: /home/me/bin/rip-cbc-radio2.sh:
    #!/bin/bash
    LEN=$1
    if [ -z "$1" ]; then
    	echo "Gimme a sec...";
    	exit 1
    fi
    streamripper "http://playerservices.streamtheworld.com/pls/CBC_R2_TOR_H.pls" -u "FreeAmp/2.x" -l $LEN -A -a "$(date +%G-%m-%d.%H-%M-%S).mp3" -s -d "/MyMusicLocation/TheSignal/" 1>&2 > /home/me/temp/streamripper.log
  6. And lastly, throw it in a cronjob to run every day (except Sunday) at 10pm for two hours (7200 seconds):
    0 22 * * 1-6 /home/me/bin/rip-cbc-radio2.sh 7200

Update September 2016!
CBC changed things up a little bit. Here’s my new script to workaround the issue (now with an id3 addition):

First, grab these guys:

sudo apt-get install libav-tools id3v2

Then pop this into a bash script /home/me/bin/rip-cbc-radio2.sh:

#!/bin/bash
LEN=$1
if [ -z "$1" ]; then
        echo "Gimme a sec...";
        exit 1
fi
base=$(date +%G-%m-%d.%H-%M-%S)
PLAYLISTURL="http://liveradiocanada.cbc.ca/i/CBCR2_TOR@382863/index_96_a-b.m3u8?sd=10&rebase=on"
avconv -i "$PLAYLISTURL" -t $LEN /home/pj/Music/TheSignal/$base.mp3
id3v2 --artist "CBC" --album "The Signal" --song "$base" --year "$(date +%G)" "$base.mp3"

And the cronjob for every day except Sunday:

0 22 * * 1-6 /home/me/bin/rip-cbc-radio2.sh 7200