Enjoying Volumio, and here's a tip too

If you want to automate the addition of BBC stations to the radio list use this script which I have modified from here 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

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 4 Extra”]="http://www.bbc.co.uk/radio/listen/live/r4x_aaclca.$
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
[/code]

Save the script somewhere as bbc.sh and run it using

. bbc.sh

Apparently the stream URLs change so if you were really clever you could add it as a cron job to run hourly. Beware the hang up problem I posted elsewhere though (with the solution.)

Fantastic! I’ll add to next release! But cron is disabled to save performances… Gonna find another way to update radio stations… Do you know how is the updating pattern (every day, week or what?) of BBC radio stations?

Unfortunately I don’t. Maybe ask the question of the person who posted the script? I’m slightly confused by it myself as I stream BBC stations from a Roku Soundbridge and some of them I haven’t changed for 6 years or so.

Hi Ianm,

The requesting URL’s such as bbc.co.uk/radio/listen/live/r2_aaclca.pls have remained static for a long time.
However, they are only half the story, if you were to use notepad.exe in windows and run the command file, open and paste that URL into the address window after a short time notepad will display the returned stream location and info.
You can try this a few times in a day and you will observe differences in the returned connection strings.

Thanks, Craig.

Thanks Craig,

I’m beginning to understand the difference between the playlist and the streaming URL. The BBC appear to change the token (possibly unique per user) which then expires after it has been idle for a period of time. I don’t know if there is an easy way around this unless MPD can open the remote playlist which seems to be the problem.

Hello, first post for me. I’ve watched (and played) with the RaspyFi project, it’s amazing to see how far things have come with Volumio. Congratulations to everyone involved.

The BBC radio streams are a bit odd. I copied a stream URL (the token URL) that had been up on the internet for over 12 months, added into the Webradio folder as an edited .pls file and it worked fine. However this morning it was dead, so I’m not sure how they work out the session handling.

Both VLC and iTunes seems to resolve the .pls to the token and use that, so once you have say:

bbc.co.uk/radio/listen/live/r6_aaclca.pls

For BBC 6 Music you can just rely on that, rather than accessing the the underlying stream URL, which in my case was.

bbcmedia.ic.llnwd.net/stream/bbc … 766dc3fec0

I was easily able to see the actual stream URL by looking at the Media Information in VLC. I’m going to see how long this one works for.

So I think I understand this now. It explains the problem I was having where the BBC Stations worked straight away I copied the pls file, but then wouldn’t work later.

It seems as if we need a method of obtaining a new pls file each time we load the station. Ie using the url for the pls file rather than the pls file itself. I am not a very competent developer but this seems as if it could be doable.

Graham

Thanks Ian,
I’m streaming BBC 6 Music now nicely :slight_smile:

One thing, that you might be able to edit, the code in your original post has an error in one line, it looks like the end of the line didn’t paste in correctly…

radios["BBC Radio 4 Extra"]="http://www.bbc.co.uk/radio/listen/live/r4x_aaclca.$
should be

radios["BBC Radio 4 Extra"]="http://www.bbc.co.uk/radio/listen/live/r4x_aaclca.pls"

Just run the script and as promised BBC streams now available… Thanks :smiley:

I’m trying to run this script on a fresh install of 1.4 for Raspberry Pi. I get an error saying unexpected EOF while looking for matching ‘"’.

Any ideas what I’ve done wrong?

I made super lightweight proxy service that I use with Volumio to stream BBC Radio:

github.com/benlancaster/BBCRadioProxy

It requests the PLS version of the BBC radio station and returns with an instruction to redirect to the tokenised stream URL, no need for cronjobs and the like.

For example, for Radio 1, you’d see the following:

curl -i http://127.0.0.1:8000/r1 HTTP/1.1 302 Moved Temporarily Location: http://bbcmedia.ic.llnwd.net/stream/bbcmedia_lc1_radio1_p?s=1407679951&e=1407694351&h=9d0677f7e9059a0532c7312965926095 Connection: keep-alive Transfer-Encoding: chunked

Just tried this out - works a charm! Thanks for sharing it.

I am a complete newbie when it comes to coding, and I know absolutely nothing about nodejs, but I couldn’t quite get the script to work as is. When trying to execute the script, I would get the following, despite entering my Pi’s IP address as an argument:

The solution, I found, was to change “hostname” on lines 25 and 28 to “host”. From what I understand, this is because “host”, not “hostname”, is defined in the script as one of the required command line arguments.

Dear All,

the script provided earlier is perfect, all be it, BBC have changed their URLs, here are the new ones

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

Many thanks, Sanjeev!

For the benefit of those who stumble onto this post, and not wanting to hunt for the original script and instructions on how to use, here is the complete working (as of October 5, 2014) script for BBC radio:

#!/bin/bash
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"

Name it say bbc.sh and make it executable. It needs to be run as root (i.e. use sudo).

It needs to be run periodically (every few hours) to update the links. There are two ways to achieve it: either enable cron on Volumio, or run cron job on another computer that ssh’es into Volumio to run the script. The former is achieved as follows: Edit

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

Commenting out the line “killall -9 cron”, and adding cron job by running

crontab -e

and adding a line

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

to the crontab (change path to the script bbc.sh as appropriate). This results in the script being run once an hour on the hour.

As mentioned above, the second solution to run cron on another computer. Here is a script for that

ssh volumio sudo /home/volumio/bbc.sh > /dev/null

That assumes that “volumio” is the hostname of volumio (or it is an alias in .ssh/config file that you use).

This is great, a really useful post and works flawlessly. One thing - how do I see the generated streams on mpdroid/mupeace. My playlists and streams are always empty.

I would be great if we could browse the listen again iplayer streams?

I found the streams weren’t playable after a reboot so I added the following to crontab:

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

I think the place to look for better iplayer support might be triode’s lms plugin for browsing Iplayer feeds and listen again? Anyone good with perl scripts?

code.google.com/p/triodeplugins/

Thanks to all the great tips and script for creating the bbc playlist.

I have manually run the script and it says that it has generated the playlist, I see a PlayList called BBC, when I browse for music, but when I click there is nothing there :frowning:

Sadly I’m not much of a programer, but able to follow simple step by step instructions, so if anyone can help let me know why this is not working as expected that would be amazing!!

Thanks

So I’ve been trying to get this to work on my new Pi2, and it just wouldn’t. The .pls links do return a valid PLS file, but the entries in them just return a 404 error - in VLC as well as Volumio. I think this might be linked to the BBC changing codecs for their Internet transmissions?

I can’t find any updated links anywhere. Any thoughts?

Have you been to the BBC API/Developer page? : bbc.co.uk/developer/

I followed the above exactly, but I am not having much luck.

The /m3u files contain:

#EXTM3U
#EXTINF:-1, BBC - BBC Radio 4

Shouldn’t it have had an address in there somewhere?