Auto Updating Tagged Radio Streams (e.g. BBC)

Not sure if I am the only one trying to get these running on Volumio - there are several posts on the Raspify site, but haven’t seen much on the new one.

The issue is that the Beeb tag their stream URLs and then change the tag number - I have no idea how often. So the web radio m3u file becomes invalid as the tag changes. MPD then dies for me and I have to reinstall in order to clear the dead link from the playlist.

Note advice seems to be to stop playing before you shutdown. I tend to just pull the power whilst playing (yes I know I probably shouldn’t).

Here I have pulled together the notes from a range of posts I used to get the BBC radio streams updating.

1) Bash script to generate the codes
Source::http://www.codedefied.co.uk/2011/12/24/playing-bbc-radio-streams-with-mpd/

[code]#!/bin/bash
set -e
playlistdir=/var/lib/mpd/music/WEBRADIO
printf “Generating BBC playlists…”

declare -A radios
radios[“Default”]=“http://www.bbc.co.uk/radio/listen/live/r4_aaclca.pls
radios[“BBC Radio 1”]=“http://www.bbc.co.uk/radio/listen/live/r1_aaclca.pls
radios[“BBC Radio 2”]=“http://www.bbc.co.uk/radio/listen/live/r2_aaclca.pls
radios[“BBC Radio 3”]=“http://www.bbc.co.uk/radio/listen/live/r3_aaclca.pls
radios[“BBC Radio 4”]=“http://www.bbc.co.uk/radio/listen/live/r4_aaclca.pls
radios[“BBC Radio 5 Live”]=“http://www.bbc.co.uk/radio/listen/live/r5l_aaclca.pls
radios[“BBC 6 Music”]=“http://www.bbc.co.uk/radio/listen/live/r6_aaclca.pls

for k in “${!radios[@]}”
do
filepath="${playlistdir}/${k}.m3u"
rm -f “$filepath”
echo “#EXTM3U” >> “$filepath”
pls=${radios[$k]}
echo “#EXTINF:-1, BBC - $k” >> “$filepath”
curl -s $pls | grep File1 | sed ‘s/File1=(.*)/\1/’ >> “$filepath”
done
printf “… generated\n”[/code]

Save this code into a file called (say) “bbc.sh”… remember where you saved it - I left it in “/home/volumio”
Then chmod 755 to make it runable.
It needs to run as root so test with

sudo ./bbc.sh

You should see the BBC link files appear in the WEBRADIO folder via Samba. Refresh the Webradio folder in the WebGUI and you should be able to play the Radio Streams. These links will expire at some point.

2 Refreshing streams at Start up
Volumio runs a script at start up to optimise the system and turn stuff off. We can sneak a line in there to run the above code. Edit the optimisation file with…

sudo nano /var/www/command/orion_optimize.sh

Look for the lines …

[code]if [ “$2” == “startup” ]; then

kill useless system processes[/code]

… then I added the following …

/bin/bash /home/volumio/bbc.sh

after the line "echo “flush startup settings” Note the line MUST be before the “fi” statement to be within the “restart” if statement.

3 Creating regular refreshes using CRON.
see http://www.raspyfi.com/forum/raspyfi-install-and-troubleshooting/cron-problem/
Volumio turns CRON off at start up to save resources. We can stop that whilst editing the “orion_optimize.sh” file. Look above where you inserted the above code and change the CRON line to

#killall -9 cron

i.e. add a # to comment the killall command.

Save and exit nano.

Right now we need to edit crontab to add our refresh command.

sudo crontab -e

NOTE: we need the script to run as root, hence the sudo

Add this to the end of the file

0 * * * * /bin/bash /home/volumio/bbc.sh

This runs the BBC refresh code every hour on the hour. Save and exit nano

4 Reboot
sudo shutdown -r now
All being well the files will refresh, CRON will now not get killed at startup and the files will also get refreshed on the hour.
There is no need to then refresh the Webradio folder each time.

Of course this is all in the hope that someone finds it useful. I had done my best to document what I did accurately. Of course I am still testing my changes and accept no responsibility.

Enjoy.

ps alternative manual refresh via web

Save the blow as bbc.php in var/www

<?php $reply = shell_exec("/home/volumio/bbc.sh"); echo $reply; ?>

Then go to volume.local/bbc.php to refresh the streams.

Thanks for this. The BBC streams thing was bugging me - a quick search and you’d already done all the work.

First thanks for this guide, it’s just what I need.

Bit confused by this bit though - what does the chmod 755 bit mean?

Also I tried the bit of code after that but it always says command not found. I tried it exactly as you put and I tried “sudo bbc.sh”. “sudo nano bbc.sh” works and the file is there so I think I have it in the same place as you in the guide.

I’m sure these are very simple questions so my apologies!

Edit: Never mind, ignored those two bits and carried on. After a restart all of them are there. Thanks!

Quick question - what’s the purpose of having “Default” in there. I can see you’ve set that as Radio 4 when there is already a Radio 4 link.

Thank you Steve ! ! !

Jawed

I tried this on a previous version of Volumio (1.2 I think) and it worked great.

However, now, on a fresh install of 1.4 I’m having trouble. The script completes and creates the m3u files in /var/lib/mpd/music/WEBRADIO, but they do not appear in the Volumio web interface. As an example, below is “BBC 6 Music.m3u”:

#EXTM3U
#EXTINF:-1, BBC - BBC 6 Music
bbcmedia.ic.llnwd.net/stream/bbc … dc32ed6cc0

Does anyone know why these playlist files are not appearing in the web interface?

Thanks

Daniel

I’m still testing it, but there seems to be a slightly simpler way:

curl open.live.bbc.co.uk/mediaselecto … at/pls.pls > /var/lib/mpd/music/WEBRADIO/Radio4.pls

mpc load WEBRADIO/Radio4.pls

Then seems to work just fine.

You could also cron mpc update as well to make it addable from the browse screen that seems to be an issue as it is.

Hope that’s helpful.

I’m also testing a very simple script as a clock radio. Similar to the one already posted but simply loading the pls directly.

C

Well it woke us up just fine, if a little loudly :slight_smile: Reset the volume, and then put some inelegant timers in to bring the volume up, as we reach some level of consciousness and then switch off as we leave.

mpc stop
mpc clear
mpc load WEBRADIO/Radio4.pls
mpc volume 1
mpc play
sleep 600
mpc volume 3
sleep 900
mpc volume 7
sleep 1800
mpc stop

Kicks off at 0450 local and if my maths is right shuts up about 0545.

Super little system all, thanks!

C

Hi, sorry for late answer I just saw now your message. Did you create subfolders in /var/lib/mpd/music/WEBRADIO ? I fixed a bug recently, when a folder contains both playlists AND subfolders, some items were not displayed ( fixed for next release, commit diff: github.com/jotak/Volumio-WebUI/ … dfd4990718 )

Running HIfi Berry DAC and Pi B and Volumio.

I have been unable to run BBC radio streams on 1.5. While surfing for a solution I found

http://radiodan.net/

and on the blog there is a pre config image. Follow instruction … once running this will provide BBC radio to HDMI port (for me anyway).

Then follow:

http://www.hifiberry.com/guides/hifiberry-software-configuration/

and BBC Radio now plays to DAC from Radiodan…

All it needs is someone to resolve this solution into next release of Volumio? (I can follow instruction but don’t understand the programming…)

Great video on their vision for future radio

http://nextrad.io/videos/dan-nutall-libby-miller-radiodan-a-cheap-flexible-and-open-ip-radio/

Credits here to Radiodan/ Volumio and hifiberry

Gareth

Thanks very much for this useful script. But I have found that the URLs in the original message no longer work as of Nov 29 2014. I updated the script with the new links. It now works again , but who knows for how long…

#!/bin/bash
#
#Generate links for BBC webradio streams. 
#
set -e
playlistdir=/var/lib/mpd/music/WEBRADIO
printf "Generating BBC playlists.."

declare -A radios
radios["Default"]="http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-aac-lc-a/vpid/bbc_radio_fourfm/format/pls.pls"
radios["BBC Radio 1"]="http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-aac-lc-a/vpid/bbc_radio_one/format/pls.pls"
radios["BBC Radio 2"]="http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-aac-lc-a/vpid/bbc_radio_two/format/pls.pls"
radios["BBC Radio 3"]="http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-aac-lc-a/vpid/bbc_radio_three/format/pls.pls"
radios["BBC Radio 4"]="http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-aac-lc-a/vpid/bbc_radio_fourfm/format/pls.pls"
radios["BBC Radio 5 Live"]="http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-aac-lc-a/vpid/bbc_radio_five_live/format/pls.pls"
radios["BBC 6 Music"]="http://open.live.bbc.co.uk/mediaselector/5/select/mediaset/http-icy-aac-lc-a/vpid/bbc_6music/format/pls.pls"


    for k in "${!radios[@]}"
    do
    filepath="${playlistdir}/${k}.m3u"
    rm -f "$filepath"
    echo "#EXTM3U" >> "$filepath"
    pls=${radios[$k]}
    echo "#EXTINF:-1, BBC - $k" >> "$filepath"
    curl -s $pls | grep File1 | sed 's/File1=\(.*\)/\1/' >> "$filepath"
    done
    printf ".... generated\n"

Hi, as of Feb 2015 BBC have removed the URLs previously mentioned in the posts. have a look at the following link http://www.bbc.co.uk/blogs/internet/entries/977a1954-658f-4fb2-a23c-71680c49882f

After a bit of messing arround I have got the following code works (today), please note I have only amended the links

[code]#!/bin/bash
set -e
playlistdir=/var/lib/mpd/music/WEBRADIO
printf “Generating BBC playlists…”

declare -A radios
radios[“Default”]=“http://www.radiofeeds.co.uk/bbcradio1.pls
radios[“BBC Radio 1”]=“http://www.radiofeeds.co.uk/bbcradio1.pls
radios[“BBC Radio 2”]=“http://www.radiofeeds.co.uk/bbcradio2.pls
radios[“BBC Radio 3”]=“http://www.radiofeeds.co.uk/bbcradio3.pls
radios[“BBC Radio 4”]=“http://www.radiofeeds.co.uk/bbcradio4fm.pls
radios[“BBC Asian”]=“http://www.radiofeeds.co.uk/bbcasiannetwork.pls

for k in "${!radios[@]}"
do
filepath="${playlistdir}/${k}.m3u"
rm -f "$filepath"
echo "#EXTM3U" >> "$filepath"
pls=${radios[$k]}
echo "#EXTINF:-1, BBC - $k" >> "$filepath"
curl -s $pls | grep File1 | sed 's/File1=\(.*\)/\1/' >> "$filepath"
done
printf ".... generated\n"

[/code]

This is an OK fix for those listenign to music, but these are the mp3 streams that are inferior in quality to the AAC streams.
They are also international streams, as opposed to natiaonal and as such, ALL sports to which the beeb doesn’t hold the international rights (e.g. footy) is blanked.

I managed to arrive at this solution myself and I am sure many will be grateful for this fix. :slight_smile:
But…
What we need is a way to play the new HLS feeds.

Here is my own post on this very subject, hopefully some people might find the background useful - but I dont yet have the solution.
https://volumio.org/forum/bbc-radio-feeds-t2620.html

Cheers!

Thanks Scaddha for updating the stations - Radio 4 makes up 80% of my Volumio use!

There is a bit of a backlash to the BBC changing to this new standard -http://www.bbc.co.uk/news/technology-31487515