Bash script for listening to online BBC radio stations using Mplayer and Linux

Here is a bash script for listening to BBC streaming Radio stations using mplayer. I modified it (24/04/2015) as the old real audio scripts (or the windows media!) were not working anymore. I also included all the available BBC radio stations and made the help output more descriptive.

The list of bbc radio streams used in the script can be found at listenlive

To install, first install mplayer

sudo apt-get install mplayer

Then save the code below as a text file (ie bbcradio) and make executable.

chmod a+x bbcradio

link to download the BBCRadio script

Then to play bbc radio 3 (for example) use the command

bbcradio 3

Just typing bbcradio will give you a reminder list of the station numbers.

bbc radio bash shell script code

#!/bin/bash bbc[0]="" bbc[1]="" bbc[2]="" bbc[3]="" bbc[4]="" bbc[5]="" bbc[6]="" bbc[7]="" bbc[8]="" bbc[9]="" bbc[10]="" bbc[11]="" bbc[12]="" bbc[13]="" bbc[14]="" bbc[15]="" bbc[16]="" bbc[17]="" bbc[18]="" bbc[19]="" bbc[20]="" bbc[21]="" bbc[22]="" bbc[23]="" bbc[24]="" bbc[25]="" bbc[26]="" bbc[27]="" bbc[28]="" bbc[29]="" bbc[30]="" bbc[31]="" bbc[32]="" bbc[33]="" bbc[34]="" bbc[35]="" bbc[36]="" bbc[37]="" bbc[38]="" bbc[39]="" bbc[40]="" bbc[41]="" bbc[42]="" bbc[43]="" bbc[44]="" bbc[45]="" bbc[46]="" bbc[47]="" bbc[48]="" bbc[49]="" bbc[50]="" bbc[51]="" bbc[52]="" bbc[53]="" bbc[54]="" bbcl[0]="" bbcl[1]="r1" bbcl[2]="r1x" bbcl[3]="r2" bbcl[4]="r3" bbcl[5]="r4" bbcl[6]="r4x" bbcl[7]="r5l" bbcl[8]="r5lsp" bbcl[9]="r6" bbcl[10]="ran" bbcl[11]="bbc_radio_three.pls" bbcl[12]="bbc_radio_berkshire" bbcl[13]="bbc_radio_bristol" bbcl[14]="bbc_radio_cambridge" bbcl[15]="bbc_radio_cornwall" bbcl[16]="bbc_radio_coventry_warwickshire" bbcl[17]="bbc_radio_cumbria" bbcl[18]="bbc_radio_derby" bbcl[19]="bbc_radio_devon" bbcl[20]="bbc_radio_essex" bbcl[21]="bbc_radio_gloucestershire" bbcl[22]="bbc_radio_guernsey" bbcl[23]="bbc_radio_hereford_worcester" bbcl[24]="bbc_radio_humberside" bbcl[25]="bbc_radio_jersey" bbcl[26]="bbc_radio_kent" bbcl[27]="bbc_radio_lancashire" bbcl[28]="bbc_radio_leeds" bbcl[29]="bbc_radio_leicester" bbcl[30]="bbc_radio_lincolnshire" bbcl[31]="bbc_london" bbcl[32]="bbc_radio_manchester" bbcl[33]="bbc_radio_merseyside" bbcl[34]="bbc_radio_newcastle" bbcl[35]="bbc_radio_norfolk" bbcl[36]="bbc_radio_northampton" bbcl[37]="bbc_radio_nottingham" bbcl[38]="bbc_radio_oxford" bbcl[39]="bbc_radio_sheffield" bbcl[40]="bbc_radio_shropshire" bbcl[41]="bbc_radio_solent" bbcl[42]="bbc_radio_somerset_sound" bbcl[43]="bbc_radio_stoke" bbcl[44]="bbc_radio_suffolk" bbcl[45]="bbc_radio_surrey" bbcl[46]="bbc_radio_sussex" bbcl[47]="bbc_tees" bbcl[48]="bbc_three_counties_radio" bbcl[49]="bbc_radio_wiltshire" bbcl[50]="bbc_wm" bbcl[51]="bbc_radio_york" bbcl[52]="bbc_radio_cymru" bbcl[53]="bbc_radio_ulster" bbcl[54]="bbc_radio_foyle" if [ $# -eq 0 ] then echo "usage bbc 1" for ((i=0; i<${#bbc[@]}; i++)) do echo $i . ${bbcl[$i]} done exit 1 fi mplayer -quiet -playlist ${bbc[${1}]}