Skip to content

Instantly share code, notes, and snippets.

@mpmckenna8
Forked from stengland/bbcradio.sh
Created July 21, 2017 19:47
Show Gist options
  • Save mpmckenna8/1e5d3a953e62454df46dbb38c771073d to your computer and use it in GitHub Desktop.
Save mpmckenna8/1e5d3a953e62454df46dbb38c771073d to your computer and use it in GitHub Desktop.
Play BBC Radio with mpd or mplayer from the command line
#!/bin/bash
play() {
playlist="http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_$1.m3u8"
echo $playlist
if mpc
then
mpc add $playlist
mpc play
else
mplayer $playlist
fi
}
if [ -z "$1" ]; then
echo "Select a station:"
select s in radio_one radio_two radio_three radio_fourfm radio_five_live 6music
do
play ${s##* }
break
done
else
play $1
fi
# GistID: 4052479
@bogstandard
Copy link

If you're happy with playing the station via your browser & don't want the effort of installing the dependencies mpc and mplayer, the following code does the job (tested on Mac only).

#!/bin/bash
play() {
  playlist="http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_$1.m3u8"
  open $playlist
}
if [ -z "$1" ]; then
  echo "Select a station:"
  select s in radio_one radio_two radio_three radio_fourfm radio_five_live 6music
  do
    play ${s##* }
    break
  done
else
  play $1
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment