--- /dev/null
+#! /bin/bash
+#
+# $Id$
+
+
+if [ "$1" = "build" ];then
+ old="`find -maxdepth 1 -name "di.fm-*" -type l`"
+ if [ -z "$old" ];then echo >&2 "No existing symlinks found.";exit 1;fi
+ newdashed="`wget -q -O - http://di.fm/|tr ' ' '\n' \
+ |perl -n -e 's/^.*"([^"]*[.](?:pls|asx))".*$/$1/ and print;' \
+ |grep -v '^/aacplus/' \
+ |tr / -`"
+ if [ -z "$newdashed" ];then echo >&2 "Failed to download the new listing found.";exit 1;fi
+ TARGET="engine-di.fm"
+ if [ ! -x "$TARGET" ];then echo >&2 "Target engine $TARGET not found.";exit 1;fi
+ rm -f $old
+ PREFIX="di.fm"
+ for pathdashed in $newdashed;do
+ ln -s "$TARGET" "$PREFIX$pathdashed"
+ done
+ echo OK
+ exit 0
+fi
+
+set -ex
+pathslashed="`basename "$0"|sed 's/^di[.]fm//'|tr - /`"
+#MEDIA=mp3
+MEDIA=aacplus
+if false;then
+ stream="`lynx -source http://di.fm${pathslashed}|sed -n 's/^File1=//p'|tr -d '\r'`"
+ exec mplayer -cache 128 "$stream"
+ exit 1
+else
+ streamlist="`lynx -source http://di.fm${pathslashed}|sed -n \
+ -e 's/^File[0-9]*=//p' \
+ -e 's#^.*"\(mms://[^"]*\)".*$#\1#p' \
+ |tr -d '\r'`"
+ for stream in $streamlist;do
+ # Using "set -e" here:
+ # mplayer rc 0 on failure to read the stream
+ # mplayer rc 0 on 'q'
+ # mplayer rc 1 on ctrl-c
+ mplayer -cache 128 "$stream"
+ done
+fi