From 1cb27aafc16edec162e03de0dd12921dc68137d9 Mon Sep 17 00:00:00 2001 From: lace <> Date: Thu, 28 Sep 2006 14:30:13 +0000 Subject: [PATCH] Extended for 'sky.fm' to find out 'ambient' is still on 'di.fm'. +Checking of unresponding servers. --- bin/engine-di.fm | 52 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/bin/engine-di.fm b/bin/engine-di.fm index f377df0..1cd49e7 100755 --- a/bin/engine-di.fm +++ b/bin/engine-di.fm @@ -4,34 +4,40 @@ if [ "$1" = "build" ];then - old="`find -maxdepth 1 -name "di.fm-*" -type l`" + old="`find -maxdepth 1 '(' -name "di.fm-*" -o -name "sky.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" + for site in di.fm sky.fm;do + newdashed="`wget -q -O - http://$site/|tr ' ' '\n' \ + |perl -n -e ' + s{^.*"(?:http://www.'$site')?([^":]*(?&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 + old="" + PREFIX="$site" + for pathdashed in $newdashed;do + test -L "$PREFIX$pathdashed" && continue + ln -s "$TARGET" "$PREFIX$pathdashed" + done done echo OK exit 0 fi set -ex -pathslashed="`basename "$0"|sed 's/^di[.]fm//'|tr - /`" -#MEDIA=mp3 -MEDIA=aacplus +pathslashed="`basename "$0"|tr - /`" if false;then stream="`lynx -source http://di.fm${pathslashed}|sed -n 's/^File1=//p'|tr -d '\r'`" - exec mplayer -cache 128 "$stream" + exec mplayer -ao oss:/dev/dsp -cache 128 "$stream" "$@" exit 1 else - streamlist="`lynx -source http://di.fm${pathslashed}|sed -n \ + streamlist="`lynx -source http://${pathslashed}|sed -n \ -e 's/^File[0-9]*=//p' \ -e 's#^.*"\(mms://[^"]*\)".*$#\1#p' \ |tr -d '\r'`" @@ -40,6 +46,16 @@ else # mplayer rc 0 on failure to read the stream # mplayer rc 0 on 'q' # mplayer rc 1 on ctrl-c - mplayer -cache 128 "$stream" + ip="` echo "$stream"|sed -n 's#^http://\([^:/]*\).*$#\1#p'`" + if [ -n "$ip" ];then + port="`echo "$stream"|sed -n 's#^http://[^:/]*:\([0-9][0-9]*\).*$#\1#p'`" + port="${port:-80}" + echo >&2 "Checking $stream -> {$ip}:{$port} ..." + if ! nc -w 2 "$ip" "$port";then + echo >&2 "TIMEOUT: $stream" + continue + fi + fi + mplayer -ao oss:/dev/dsp -cache 128 "$stream" "$@" done fi -- 1.8.3.1