#! /bin/sh

RADIO=/mnt/temp/radio
DATEFORMAT=+%a_%d.%m.%y_%H.%M

TITLE=$1
CHANNEL=$2
DURATION=$3

if [ "$CHANNEL" = "France Musique" ]; then
		url="http://www.tv-radio.com/station/france_musique_mp3/france_musique_mp3-128k.asx"
fi

if [ "$CHANNEL" = "Radio Classique" ]; then
		url="http://www.tv-radio.com/station/classique-mp3/classique-mp3-128k.pls"
fi

if [ "$CHANNEL" = "France Info" ]; then
		url="http://str2.creacast.com/france_info_64"
fi

date=$(date $DATEFORMAT)
title=$(echo $TITLE | sed 's/ /_/g')
channel_name=$(echo $CHANNEL | sed 's/ /_/g')

mplayer -playlist $url -vc dummy -vo null -dumpstream -dumpfile $RADIO/$title-$channel_name-$date.mp3 &

pid=$!
sleep $DURATION
kill $pid

