1 (edited by PaperClippy 2014-03-09 00:40:25)

Topic: internoderadio.sh - Maintains Internode unmetered radio list

Hi all,

Here's a script I developed to keep the Internode unmetered content updated in My Streams on my chumby, and includes all unmetered content (not just the shorter list in the Internode radio audio source).

This script should keep your custom streams across refreshes and only update the internode unmetered streams (either way it makes a backup anyway). Custom entries will appear at the top of the new list, with the internode items following.

Anyway I hope someone finds this useful and if not be gentle as this script is not much more than a series of ugly grep and sed hacks! wink

Enjoy!
Clippy

PS: If you used servalan's listing from here ( http://forum.chumby.com/viewtopic.php?id=3222 ) you will need to delete those entries manually (sorry!) as she linked to the source stream whereas I have linked to the playlist which contains a link to the source stream

#!/bin/sh

# setup

ignored_streams="(low)"
high_priority_streams="SomaFM|SkyFM|DI:|Afterhours|80s|ABC Classic|Jazz|Lounge|Cody|ETN|Swiss"
low_priority_streams="ChroniX"

target_file=/psp/url_streams
src_url=http://media.on.net/radio.php?mode=playlist

tmp_prefix=/tmp/InterNodeFreeRadio.$$

# housekeeping

touch $target_file

#head $target_file

# backup to be sure

echo Backing up $target_file to $target_file.backup ...
cp -f $target_file $target_file.backup

# download source url

echo
echo Downloading Internode unmetered content listing...
echo 
wget --output-document=$tmp_prefix.pls $src_url

# horribleness to parse out the stream names and locations

echo Parsing Internode unmetered content listing...
egrep "^File|^Title" $tmp_prefix.pls | sed "N;s/\n/ /" | sed 's/^File/<stream id="/g;s/=http/" mimetype="audio\/mpeg" url="http/g;s/Title[0-9]*=/name="Node: /g;s/ name="/" name="/g;s/$/" \/>/g' | egrep -i -v "$ignored_streams" | sed 's/Digitally Imported/DI/g;s/Sky.FM -/SkyFM:/g;s/ (High)//g;s/&/and/g' | sed "s/'//g" > $tmp_prefix.incoming.tmp
#head $tmp_prefix.incoming.tmp
echo `grep -i url= $tmp_prefix.incoming.tmp | wc -l | sed 's/\/.*$//g'` unmetered streams found.

# more horribleness to parse out free streams from the existing list

echo Parsing existing my My Streams content...
sed 's/></>\n</g' $target_file | grep -i "url=" | grep -i -v "http://[^.]*.internode.on.net" | uniq > $tmp_prefix.current.tmp
#head $tmp_prefix.current.tmp
echo `grep -i url= $tmp_prefix.current.tmp | wc -l | sed 's/\/.*$//g'` personal streams found.
cat $tmp_prefix.current.tmp

# join 'em up

# echo
echo Updating My Streams content...
echo "<streams>"              > $tmp_prefix.outgoing.tmp
cat $tmp_prefix.current.tmp  >> $tmp_prefix.outgoing.tmp
cat $tmp_prefix.incoming.tmp | egrep -i  "${high_priority_streams}" | egrep -iv "${low_priority_streams}" >> $tmp_prefix.outgoing.tmp
cat $tmp_prefix.incoming.tmp | egrep -iv "${high_priority_streams}" | egrep -iv "${low_priority_streams}" >> $tmp_prefix.outgoing.tmp
cat $tmp_prefix.incoming.tmp | egrep -iv "${high_priority_streams}" | egrep -i  "${low_priority_streams}" >> $tmp_prefix.outgoing.tmp
echo "</streams>"            >> $tmp_prefix.outgoing.tmp

# finished product

cat $tmp_prefix.outgoing.tmp > $target_file

# done

echo `grep -i url= $target_file | wc -l | sed 's/\/.*$//g'` streams now in My Streams list.
echo

sync

grep -i "stream id" ${target_file} | sed 's/^.* name="//g;s/".*$//g'

echo

# clean up

rm -f $tmp_prefix*

Re: internoderadio.sh - Maintains Internode unmetered radio list

ok - dumb question - how do I run this script?

Re: internoderadio.sh - Maintains Internode unmetered radio list

Please write the debugchumby script... smile

4 (edited by PaperClippy 2009-04-26 02:41:32)

Re: internoderadio.sh - Maintains Internode unmetered radio list

Not a dumb question at all, only a dumb assumption by me... I forgot to put together decent usage instructions... sad

Basically you need to copy this file to somewhere on your chumby, and run it, but if you knew how to do do that I guess you would not be asking... lol

Easiest way I have found (and the cleanest as to not be leaving random scripts around the chumby) is to have a USB drive dedicated for chumby stuff.

This USB stick needs to be formatted (while connected to your PC) as FAT32 (not ntfs).

Once you have the USB stick setup on your PC, use something like notepad++ (a fantastic piece of software, download from http://notepad-plus.sourceforge.net/uk/site.htm) to create a file called internoderadio.sh and make sure you select 'Convert' -> 'Convert to Unix Format' before you save the file (at least that's how you do it on notepad++).

Then eject the USB stick from your PC, plug it in to your chumby in 'USB A', and power cycle the chumby (actually I don't know if this is needed but I can never get it to recognise my USB drives without a power cycle).

Then you need to enable shh on your chumby (see http://wiki.chumby.com/mediawiki/index. … trol_Panel and/or http://wiki.chumby.com/mediawiki/index. … at_startup ) and login to your chumby using something like putty (download from http://www.chiark.greenend.org.uk/~sgtatham/putty/ and for chumby login instructions see http://wiki.chumby.com/mediawiki/index. … the_chumby ).

Once logged in, type the following commands:

cd /mnt/usb
chmod +x internoderadio.sh
./internoderadio.sh

The first one changes to the correct directory on the USB stick, the second makes the file able to be run, the last runs the script.

Next time you run the script you only need the first and last lines

hth

Re: internoderadio.sh - Maintains Internode unmetered radio list

Ah - Thanks - I wonder if you could put that in a debugchumby file? So it autoruns or perhaps running it everyday would be excessive.

Thanks for the instructions. I use Editpad Lite which does the unix linefeeds and had already discovered the putty program and ssh when I was playing with the streams file.

Re: internoderadio.sh - Maintains Internode unmetered radio list

Hmm - yeah running it daily might be excessive as the list does not change all that often, if at all of late.

Plus putting it in debugchumby might result in it running before the network is up and running.

Maybe cron it to run weekly?

7 (edited by PaperClippy 2010-03-16 17:42:00)

Re: internoderadio.sh - Maintains Internode unmetered radio list

Updated to support the recent(ish) Internode media server move.
Also now uses the Internode supplied playlist instead if parsing from html.

Re: internoderadio.sh - Maintains Internode unmetered radio list

Updated (or revived!) fresh for 2014... :-)