#!/bin/bash
# Check for command-line arg.
ARGCOUNT=3
E_WRONGARGS=65
if [ $# -ne "$ARGCOUNT" ]
then
echo "Usage: `basename $0` stream length outfile"
exit $E_WRONGARGS
fi
STREAM=$1
LENGTH=$2
OUTFILE=$3
STREAMCMD="streamripper $STREAM -s -A -a %d.ogg -l $LENGTH -m 600 --quiet 2>&1 | tail -1 | awk '{print $1}'"
TIME=$(date +%Y-%m-%d_%H%M)
#create a temp folder to put the capture files in
TMPFOLDER="/var/tmp/airtime/rips/streamipper-$TIME"
if [ ! -d "TMPFOLDER" ]; then
mkdir -p $TMPFOLDER
fi
#Record the stream with streamripper. It is possible the stream is not available in which case streamripper
#will giveup. So try a few times... streamripper http://host:8000/stream.ogg -s -A -a %d.ogg -l 22000 -m 600
nTrys=0
maxTrys=5
status="error"
until [[ "$status" != error* ]] ; do
echo "recording with command: streamripper $STREAM -s -A -a $TMPFOLDER/%d.ogg -l $LENGTH -m 600 --quiet"
status=$(streamripper $STREAM -s -A -a $TMPFOLDER/%d.ogg -l $LENGTH -m 600 --quiet 2>&1 | grep error)
nTrys=$(($nTrys + 1))
if [ $nTrys -gt $maxTrys ] ; then
echo "Number of re-trys exceeded. Quitting"
exit
fi
if [[ "$status" == error* ]] ; then
echo "$status retry $nTrys"
sleep 5
fi
done
#At this point we have one or more files in the XXX folder which we need to merge with sox
/usr/bin/sox $TMPFOLDER/*.ogg $OUTFILE
echo "merging files with command: /usr/bin/sox $TMPFOLDER/*.ogg $OUTFILE"
# then we should be done!
# you may want to delete something
#rm $TMPFOLDER/*.ogg
#rmdir $TMPFOLDER
If you wanted to break it up you could simply schedule Airtime to record shorter shows - E.g. two half hour shows instead of one full hour. Does that help?
This solution is for recording according to the Airtime Calendar - the length is set by Airtime. You just set up the show to record, and then it will appear in the library when it is done. The difference is that it records from a stream rather than the sound card.I've attached a slightly updated version of the script.
It looks like you're new here. If you want to get involved, click one of these buttons!