#!/bin/sh

# If you use this script, please support National Public Radio.
# Please donate either to your local radio station.  If you haven't a
# local station, consider donating to WDUQ (my old Pittsburgh station,
# www.wduq.org), WHYY (www.whyy.org, Philadelphia, home of Fresh Air)
# or WBEZ (www.wbez.org, Chicago, home of This American Life).  Or
# heck, KOSU (www.kosu.org, Stillwater, OK, the first NPR station I
# listened to).

directory=/storage/multimedia/npr

suff=""

while getopts "r:m" Option
# Initial declaration.
do
  case $Option in
    r ) directory=$OPTARG
    ;;
    m ) suff=mp3
    ;;
  esac
done
shift $(($OPTIND - 1))

# Move argument pointer to next.
prgcode=$1

cd $directory/$prgcode/$suff

if ls *.wav
then 
  mplayer *.wav
else
  mplayer *.mp3
fi