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.
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.
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:
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.
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"
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:
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.
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 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?
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
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!!
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?