This example works on my Ubuntu 10.0 Maverick Meerkat desktop system but the components are universal enough that it should work on other distributions as well (e.g. CentOS/RHEL)

  1. Install vlc-nox ( this is vlc with no X Windows support AKA command line only ) and vorbis-tools ( this is used to add metadata to the audio file )
    sudo apt-get install vlc-nox vorbis-tools
    
  2. Establish a https://www.dropbox.com/ account
  3. Create a directory in your dropbox which is shared publicly called “Public/kalx”
  4. Determine the public URL of this new publicly shared Dropbox folder and set it in the script variable below called “dropboxurlprefix”
  5. Create the following script. For our purposes we’ll assume it’s located in “/home/username/record-kalx.bash
    #!/bin/bash
    
    # cron
    # This cron line would record every Thursday starting at 6pm
    #0 18 * * 4 /home/username/record-kalx.bash 2>&1 >> /home/username/record-kalx.log
    
    # ######### CONFIGURATION ############
    # To save as an mp3
    #url="http://icecast.media.berkeley.edu:8000/kalx-128.mp3"
    #acodec="mp3"
    #ext="mp3"
    #mux="raw"
    
    # To save as an ogg
    url="http://icecast.media.berkeley.edu:8000/kalx-128.ogg"
    acodec="vorb"
    ext="ogg"
    mux="ogg"
    
    arate="128"
    vlc="/usr/bin/vlc" 
    
    # How long would you like to let the recording run for?
    # 10800 seconds is 3 hours
    #recordingduration=60
    recordingduration=10800
    
    toolpath="/home/username"
    outputpath="/home/username/Dropbox/Public/kalx"
    dropboxurlprefix="http://dl.dropbox.com/u/31132/"
    
    tempdir="$toolpath"
    outputfile="kalx-radio-`date +%Y%m%d%H%M%S`.$ext" 
    playlistdate="`date +%m-%d-%Y`"
    
    noninteractive="-I dummy"
    #listenalso="duplicate{dst=display,dst="
    
    # ####################################
    
    date
    ($vlc $noninteractive --http-caching 5000 -vvv --sout "#transcode{acodec=$acodec,ab=$arate,channels=2}:${listenalso}std{access=file,mux=$mux,dst=$tempdir/$outputfile}}" "$url" 2>&1 >> $toolpath/test.log) &
    pid=$!
    sleep $recordingduration
    kill $!
    sleep 10
    date
    
    # This next command will add a description field into the audio file with a link to the playlist for the show. Unfortunately
    # to do so I need to know the show ID. Since I have been recording only my own show it's hard coded in "484". To make this
    # dynamic one would have to dynamically determine the showoid at a given point in time to build the playlist URL
    #vorbiscomment -t "DESCRIPTION=http://kalx.radioactivity.fm/playlist.html?showoid=484&date=$playlistdate" -a $tempdir/$outputfile
    
    mv $tempdir/$outputfile $outputpath
    
    # Here we create a playlist containing all of the pulic recordings
    >$outputpath/kalx.m3u
    for filename in `cd $outputpath;ls *.ogg`; do
        echo "$dropboxurlprefix/kalx/$filename" >>$outputpath/kalx.m3u
        echo "$dropboxurlprefix/kalx/$filename" >>$outputpath/kalx-radio-$playlistdate.m3u
    done
    
  6. Finally create a cron job to kick off this script
    sudo bash -c "echo '0 18 * * 4 username /home/username/record-kalx.bash 2>&1 >> /home/username/record-kalx.log' >/etc/cron.d/record-kalx.cron"