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.