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]="http://www.listenlive.eu/bbcradio1.m3u" bbc[2]="http://www.listenlive.eu/bbcradio1x.m3u" bbc[3]="http://www.listenlive.eu/bbcradio2.m3u" bbc[4]="http://www.listenlive.eu/bbcradio3.m3u" bbc[5]="http://www.listenlive.eu/bbcradio4.m3u" bbc[6]="http://www.listenlive.eu/bbcradio4extra.m3u" bbc[7]="http://www.listenlive.eu/bbc5live.m3u" bbc[8]="http://www.listenlive.eu/bbc5liveextra.m3u" bbc[9]="http://www.listenlive.eu/bbcradio6.m3u" bbc[10]="http://www.listenlive.eu/bbcasian.m3u" bbc[11]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-aac-lc-a/format/pls/vpid/bbc_radio_three.pls" bbc[12]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_berkshire/format/pls.pls" bbc[13]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_bristol/format/pls.pls" bbc[14]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_cambridge/format/pls.pls" bbc[15]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_cornwall/format/pls.pls" bbc[16]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_coventry_warwickshire/format/pls.pls" bbc[17]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_cumbria/format/pls.pls" bbc[18]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_derby/format/pls.pls" bbc[19]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_devon/format/pls.pls" bbc[20]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_essex/format/pls.pls" bbc[21]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_gloucestershire/format/pls.pls" bbc[22]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_guernsey/format/pls.pls" bbc[23]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_hereford_worcester/format/pls.pls" bbc[24]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_humberside/format/pls.pls" bbc[25]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_jersey/format/pls.pls" bbc[26]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_kent/format/pls.pls" bbc[27]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_lancashire/format/pls.pls" bbc[28]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_leeds/format/pls.pls" bbc[29]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_leicester/format/pls.pls" bbc[30]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_lincolnshire/format/pls.pls" bbc[31]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_london/format/pls.pls" bbc[32]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_manchester/format/pls.pls" bbc[33]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_merseyside/format/pls.pls" bbc[34]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_newcastle/format/pls.pls" bbc[35]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_norfolk/format/pls.pls" bbc[36]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_northampton/format/pls.pls" bbc[37]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_nottingham/format/pls.pls" bbc[38]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_oxford/format/pls.pls" bbc[39]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_sheffield/format/pls.pls" bbc[40]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_shropshire/format/pls.pls" bbc[41]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_solent/format/pls.pls" bbc[42]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_somerset_sound/format/pls.pls" bbc[43]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_stoke/format/pls.pls" bbc[44]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_suffolk/format/pls.pls" bbc[45]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_surrey/format/pls.pls" bbc[46]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_sussex/format/pls.pls" bbc[47]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_tees/format/pls.pls" bbc[48]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_three_counties_radio/format/pls.pls" bbc[49]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_wiltshire/format/pls.pls" bbc[50]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_wm/format/pls.pls" bbc[51]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_york/format/pls.pls" bbc[52]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_cymru/format/pls.pls" bbc[53]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_ulster/format/pls.pls" bbc[54]="http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_foyle/format/pls.pls" 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}]}