How I manage Lunchbox Radio

July 30 20082 comments | post comment

Lunchbox Radio

We use Nicecast to do live broadcasting at Lunchbox Radio, and we were using it for general broadcasting of our iTunes library. The overhead to do that on this aging G4 was getting to be too much, and we couldn’t do much to manage the system unless we were physically at the box or using Remote Desktop (OSXVNC-server and Chicken of the VNC actually). It makes more sense to use Shoutcast’s DNAS to do the work since it doesn’t require iTunes or Nicecast to be running. We will still use Nicecast to do live shows and Jager Hour stuff of course.

We have two types of playlists. Full DJ Mixes and Single Tracks. I use a couple of scripts to help automate changing playlists and generating playlists when we add new music. Here are those scripts:

gen_playlist.sh:

#!/bin/bash
if [ -z $1 ]
then
    
echo "You must specify either single or mixes"
    
exit
fi
TYPE
=$1;

echo
"Generating Playlist $TYPE.lst"

find /path/to/music/directory/$TYPE -type f -name "*.mp3" > $TYPE.lst

echo "Playlist complete..."

You pass one parameter to gen_playlist.sh, and that is the name of the directory and playlist you want to create. To keep things simple, the playlist has the same name as the directory, so our mixes playlist is built from our mixes directory.

To reload the playlist we first need to update the sc_trans.conf file, then send a signal to the running program.

update_sc.sh

#!/bin/bash

## CONFIG ##
ConfFile=/path/to/shoutcast/sc_trans.conf

if [ -z $1 ]
then
    
echo "You must specify either single or mixes"
    
exit
fi
TYPE
=$1;

# edit sc_trans.conf

# get pid and send HUP signal
PID=` ps wwax | grep -i "[s]c_trans_macosx" | awk '{ print $1 }'`
echo
PID = $PID

echo Updating conf file - $ConfFile

SED
=`which sed`

# make backup of conf file
cp $ConfFile $ConfFile.bak

`$SED -i.bak "s/single.lst/$TYPE.lst/g" $ConfFile`
`
$SED -i.bak "s/mixes.lst/$TYPE.lst/g" $ConfFile`

echo
Restarting Broadcast
kill
-USR1 $PID

echo Playlist, $TYPE, Loaded!

This script also takes one parameter, the name of our playlist (mixes or single). We rewrite the conf file with our new playlist (we make a backup just in case something goes wrong), then send the signal to the program to reload the playlist. From here you can force it to change to the next song in the list, but I prefer to just let it play out.

A lot could be improved on, but it works for now.

Now if only we could actually keep our internet connection up. That would be amazing. 

Comments

1    mreid   September 04 2008

let’s say you have an iTunes playlist you’ve already made in iTunes and you want to get those files to an export directory for reading in on shoutcast, here’s a script that will parse the iTunes xml file that you exported for the playlist and scp them from the music host to the streaming host. Checks to make sure they’re mp3 and not DRM AAC.

Might be useful, might not.

#!/bin/sh
COUNTER=0
cat inputfile.xml |
grep “<key>Location</key>” |
grep “.mp3” |
awk -F “<string>” {’print $2’} |
sed ‘s/&/\&/g’ |
sed “s/’/\\\’/g” |
sed “s/’/\\\’/g” |
sed ‘s/&/\\\\&/g’|
sed ‘s/#/\\\\#/g’|
sed ‘s/;/\\\\;/g’|
sed ‘s/<\/string>//g’|
sed ‘s/\/\\\\ /g’ |
sed ‘s/\[/[/g’ |
sed ‘s/\]/]/g’ |
sed ‘s/(/\\\\(/g’|
sed ‘s/)/\\\\)/g’|
sed ‘s/!/\\\\!/g’|
sed ‘s/%/\\\\%/g’|
sed ‘s/\ /\\ /g’|

sed ‘s/file:\/\/localhost//g’ |

while read line; do
COUNTER=`expr $COUNTER + 1`
echo “”
echo “COPY: $line”
rsync -av --progress :"${line}" TO_GARMIN/
CODE=$?
echo “CODE=$CODE”
echo “COUNTER=$COUNTER”
if [ “$CODE” != “0” ]; then
echo “FAILED: $CODE: $line” >> failed.txt
fi

done

2    ecsyle   September 09 2008

Awesome idea, thanks!

You need to register or log in to leave a comment.