Skip to content

Instantly share code, notes, and snippets.

@abozhilov
Created September 20, 2011 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abozhilov/1230188 to your computer and use it in GitHub Desktop.
Save abozhilov/1230188 to your computer and use it in GitHub Desktop.
Radio player
#!/bin/bash
#Available radio streams
RADIO_NAMES=(
"Дарик Радио"
"Радио 1"
"Радио 1 Рок"
"БГ Радио"
"Радио Вероника"
"Радио Веселина"
"Радио Витоша"
"Радио Energy"
"Радио N-Joy"
"Радио Z-Rock"
"Радио City"
"Радио Star FM"
"Радио FM+"
"Радио Fresh!"
)
RADIO_STREAM=(
"http://mp3.orbitel.bg:8000/darik.m3u"
"http://80.72.68.217/radio1.ogg.m3u"
"http://80.72.68.217/radio1rock.ogg.m3u"
"http://80.72.68.217/bgradio.ogg.m3u"
"http://80.72.68.217/veronika.ogg.m3u"
"http://193.108.24.18:8000/veselina.m3u"
"http://193.108.24.18:8000/vitosha.m3u"
"http://80.72.68.217/nrj.ogg.m3u"
"http://pulsar.atlantis.bg:8000/njoy.ogg.m3u"
"http://pulsar.atlantis.bg:8000/zrock.ogg.m3u"
"http://62.204.145.218:8000/city64.m3u"
"http://pulsar.atlantis.bg:8000/inforadio.ogg.m3u"
"http://pulsar.atlantis.bg:8000/fmplus.ogg.m3u"
"http://193.108.24.21:8000/fresh.m3u"
)
#Error statuses
OUT_OF_RANGE=1
INVALID_ARGUMENT=2
#Print help menu
if [ -z "$1" -o "$1" = "-h" -o "$1" = "--help" ]
then
echo "Usage: ./radio [OPTION]... [RADIO INDEX]...
Radio script is intended to play an online radio streaming. It requires mplayer.
-l List of available radios
-p Play radio from list
-h, --help Prints this help";
#Print the list of radios
elif [ "$1" = "-l" ]
then
i=0
while [ "$i" -lt "${#RADIO_NAMES[*]}" ]
do
echo $i "-" ${RADIO_NAMES[$i]}
((i++))
done
#Play choisen radion
elif [ "$1" = "-p" ]
then
if [ -n "${RADIO_STREAM[$2]}" ]
then
mplayer -playlist ${RADIO_STREAM[$2]}
exit $?
else
echo "Out of range. Please see the list of available radios."
exit $OUT_OF_RANGE
fi
#Handle undefined arguments
else
echo "Use -h for help"
exit $INVALID_ARGUMENT
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment