You are not logged in.
Pages: 1
This uses the excellent beebotron site which serves up all the available BBC "listen again" radio programmes in html files with links that most media players can use. This means you don't have to use the heavy flashbound iplayer. The full list is here: http://beebotron.org/index3lite.php but this script uses the music genre selection. Even that list is huge and would give you an enormous menu, so there's some filtering you should tweak to get the selections you want. Anyway, usage is like any pipe menu, dependencies - nothing special, though radiotray's nice. If you've got a slow internet connection downloading the 200KB file will slow the menu down quite a bit, so add '/path/to/beebotron.sh --refresh &' to your autostart file to get it out of the way. Anyway here it is:
#!/bin/bash
# beebotron.sh - a script to download a list of
# recent bbc radio programmes from beebotron.org
# and generate an openbox pipe menu
# version 12/04/11 added optional top menu items
# Usage: add
# <menu id="beebotron" label="BBC Music Programmes" execute="/path/to/beebotron.sh" />
# to your .config/openbox/menu.xml
# The first time it is run that day the cache file will be downloaded,
# which will make the menu slow to pop out. You can avoid that by adding:
# /path/to/beebotron.sh --refresh &
# to your openbox autostart(.sh) file.
# choose player for radio (see lines 45-47 below)
player=radiotray
# choose url to download
url=http://beebotron.org/public3/genremusic.html
# Other genres are: genrechildrens, genrecomedy, genredrama, genrefactual,
# genrelearning, genrenews, genrereligethics, genresport, genreweather
# - substitute for genremusic above.
# If you live in the UK you can use the high quality links, which end with "hq"
# url=http://beebotron.org/public3/genremusichq.html
CACHE_FILE=$HOME/.cache/beebotron_music # where to keep the cache file
# (change name to match genre)
#######################################
## FILTERS using regular expressions ##
# If you don't filter the list the menu will be very long.
# Entry descriptions are in the html file, but not displayed in the menu.
# Any entries (including descriptions) matching the expression will be put at the top of the menu
# and further filters will be ignored.
#top='(^My Favourite Prog Title|^This Too)'
top='(^World on 3|^World Routes)'
# Any entries (including descriptions) matching the expression will be skipped.
#skip='([Bb]ach|[Bb]eethoven)'
#skip='a^' # nothing matches this
skip='(^1Xtra|^Breakfast|^C2|^The Early Show |^The Evening Show)'
# Any entries (including descriptions) NOT matching the expression will be skipped.
only='([Jj]azz|[Ww]orld|[Aa]sia|[Rr]eggae|[Bb]hangra|[Bb]lues|India|Pakistan|^Don Letts)'
#######################################
[[ $1 = "--refresh" || ! -f $CACHE_FILE || $(( $(date +%s) - $(stat -c %Z "$CACHE_FILE") )) -gt 86400 ]] && {
wget -q -O "$CACHE_FILE" "$url"
}
[[ $1 = "--refresh" ]] && exit
# start up radiotray in background if it's not already running
# Comment out this line if you don't use radiotray:
pgrep radiotray >/dev/null || { ( radiotray >/dev/null 2>&1 & ); sleep 1;}
awk -v TOP="$top" -v SKIP="$skip" -v ONLY="$only" -v PLAYER="$player" 'BEGIN {
MENU=TOPMENU=""
PRE=" <item label=\""
MID="\">\n <action name=\"Execute\"><command>" PLAYER " \""
POST="\"</command></action>\n </item>"
RS="<a href=\""
FS="\">"
}
/DOCTYPE/ {next}
/http:\/\/beebotron.org/ {exit}
# $1 is the url, $2 the name
$2 ~ TOP {
sub(/<\/a>.*$/,"",$2)
TOPMENU = TOPMENU "\n" PRE $2 MID $1 POST
next
}
$2 ~ SKIP {next}
$2 !~ ONLY {next}
{
sub(/<\/a>.*$/,"",$2)
MENU = MENU "\n" PRE $2 MID $1 POST
}
END {print ("<openbox_pipe_menu>" TOPMENU "\n <separator/>" MENU "\n</openbox_pipe_menu>")}
' "$CACHE_FILE"
exitHope you like it. 
edit 2012/4/5 The BBC's urls seem to have changed, (temporarily?) breaking the script (and the beebotron) for international users. See post below.
edit 2012/4/12 The url issue seems to be OK now. Either the BBC got their act together or Kronalias at the Beebotron fixed it. The script has also been updated - now you can add a top menu section for favourites.
Don't forget to edit the filters to suit your own tastes!
Last edited by johnraff (2012-04-12 12:00:30)
John
--------------------
( a boring Japan blog , and idle twitterings )
Offline
This is so cool. Thanks 
"To me, the extraordinary aspect of martial arts lies in its simplicity. The easy way is also the right way, and martial arts is nothing at all special; the closer to the true way of martial arts, the less wastage of expression there is." - Bruce Lee
Offline
John,
thank you, thank you, it works and it's great! I love your scripts 
Offline
Great script (as ever).
Many thanks.
Offline
At least half the credit to the guy that runs that beebotron site.
(but thanks anyway
)
John
--------------------
( a boring Japan blog , and idle twitterings )
Offline
Thanks for your work as well Kronalias!
Top stuff.
Offline
Hi Kronalias! A great service you're providing there. I've been using it a while now - since the days of realplayer links.
...and welcome to Crunchbang 
John
--------------------
( a boring Japan blog , and idle twitterings )
Offline
The BBC seem to have changed something, and the urls that the Beebotron fetches no longer work for international listeners. See here. A couple of workarounds came up in that thread, but lets see if things stabilize a bit and then I'll try and rehack the script if necessary.
John
--------------------
( a boring Japan blog , and idle twitterings )
Offline
^That issue seems to be fixed now, needing no hacks at this end. I celebrated by updating the script a little. Got fed up with having to scroll down to the bottom of the menu to get to my favourite programmes "World Routes" and "World on 3" so added the option of putting some selected items at the top. 
(Also moved some of the code from bashzone to awkzone and got a 30% speedup. Awk is fast.)
John
--------------------
( a boring Japan blog , and idle twitterings )
Offline
@Johnraff
Has the cache structure changed since beebotron service stopped and restarted?
How does the filter work? I used to have the filter expression:
# Any entries not matching the expression will be skipped.
only='([Hh]istory|[Ss]cience|[Nn]ature)'
I am sure I get different results now; and looking at the cache I cant work out what this expression would act
on, since the cache entries appear to be short synopsis of the programme rather than the genre (sub-)categories
The above filter was designed on the categories which get-iplayer delivers; and I am sure, used to deliver a correct menu list. To be honest, I cant actually rember the whether I studied the cache structure before.
Is the only filter now available the actual programme name, as in the script example
top='(^World on 3|^World Routes)' because only='([Jj]azz|[Ww]orld|[Aa]sia|[Rr]eggae|) type filtering only seems to be effective if the synopsis contains the Key words
Offline
Hi UkDkDe, no nothing's changed with the beebotron service afaik, and in the script, a little code was moved from bash to awk, and an extra option for "top" menu items added. My menu seems to be working fine.
The cache file is just the html as downloaded. Apart from the stuff at the top and bottom, each entry looks like this:
<a href="http://www.bbc.co.uk/mediaselector/4/asx/b01g4mxg/iplayer_intl_stream_wma_lo_concrete">100% HomeGrown with DJ Target, DJ Cameo's Lyrical Master and Nicky Blackmarket D&B mix</a> - Cameo is in to chat about Lyrical Master - get online fast if you're the next big thing! [5 days 12 hours]<br>So the part between <a href="blahblahblah"> and </a> is used as the menu title, and the description after that is thrown away, though both the title and desription are checked against the regular expression filters.
Three filters are available as before:
top - matching entries go in the top menu section even if they match the 'skip' filter, and regardless of whether they're included in the 'only' filter.
skip - matching entries are skipped, even if they match the 'only' filter.
only - entries which don't match are skipped.
I'm not sure if the 'skip' filter is any use really - I thought skipping certain entries like '^1Xtra' at the beginning of the string would speed things up by avoiding checking for possible 'only' matches the full length of the string, but it didn't seem to make much difference to the execution time. But it does no harm.
Don't forget, the caret ^ anchors the expression to the beginning, so '^1Xtra' matches '1Xtra music' but not 'Music on 1Xtra'.
The only other thing I wonder is if you set the download url to the genre you want. The default is genremusic.html, which is unlikely to have many results for a filter of only='([Hh]istory|[Ss]cience|[Nn]ature)' 
John
--------------------
( a boring Japan blog , and idle twitterings )
Offline
Hi Johnraff, been working through this and I understand where I am going wrong now
My original use of this script was just for comedy. I tried to extend it to factual.
My comedy genre version is unfiltered - produces an unfiltered pipemenu of circa 100 items
The factual version produces an enormous pipe menu (presumably almost the full cache) since the filter
only='([Hh]istory|[Ss]cience|[Nn]ature)' has no/little impact.
Reading through the cache of genrefactual, it looks like filtering down to sub-genres like Nature
or Science will not work.Sorry, my mistake; I thought beebotron was picking up the same sub-categories
as get-iplayer does eg. (using your example above, the get_iplayer categorisation is)
"HomeGrown with DJ Target - WORLD EXCLUSIVE: BRAND NEW WILEY, BBC 1Xtra, Dance & Electronica,Drum & Bass,Experimental & New,Garage,Hip Hop R'n'B & Dancehall,Music,Radio"
which would allow a very targeted filter - in this case a "skip" filter 
Nevertheleess, a super pipemenu for comedy , thank you!
Offline
Pages: 1
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.