#!/bin/sh -x
#---------#---------#---------#---------#---------#---------#---------#---------
# title
#   record a BBC AOD (Audio On Demand) stream from realplayer to MP3
# author
#   larg 05 jun 2006
# description
#    A script to record a BBC AOD (Audio On Demand) stream from realplayer to MP3.
#    AOD URL:  http://www.bbc.co.uk/radio/aod/mainframe.shtml?http://www.bbc.co.uk/radio/aod/index.shtml?button
#    I date each mp3 I record, but this is not hugely accurate. 
#    This program is broadcast some days earlier than when I get around to 
#    recording it.
#
# also see 
# * BBCsummary.sh  
# * audio-breezeblock.sh  
#
# mplayer options
# flags galore
# -nojoystick -nolirc - no joystick or remote control support
# -noframedrop  - don't try to keep realtime by dropping frames. 
#                 May only apply to video, I dunno.
# -softsleep    - use a pretend clock, not the rtc (RealTimeClock)
# -prefer-ipv4  - assume the network is IPv4, not IPv6 (eg. for DNS)
# -ao pcm:file=FILE  audio output driver to use. Redirects to file FILE
# -vc           - video codec. Turned off using dummy device null.
# -vo           - video output driver. Turned off.
#
# 
#---------#---------#---------#---------#---------#---------#---------#---------
# prepare
file="6mix-`date -u "+%y%m%d"`"
tracktitle="6mix (recorded `date -u`)"
#
# capture, convert & clean up
mplayer \
    rtsp://rmv8.bbc.net.uk:554/6music/6m_6mix.ra \
    -nojoystick -nolirc -noframedrop \
    -softsleep  -prefer-ipv4 \
    -ao pcm:file=$file.wav   \
    -vc null    -vo null     \
&& \ 
lame \
    -q 2 -V 3  \
    --replaygain-accurate --resample 44.1 \
    --tt "$tracktitle" --ta "6 Music" --tc "BBC" \
    --add-id3v2 --pad-id3v2 \
    $file.wav $file.mp3 \
&& \
rm -vf $file.wav
#
#---------#---------#---------#---------#---------#---------#---------#---------
