6 if [ "$1" = "build" ];then
7 old="`find -maxdepth 1 '(' -name "di.fm-*" -o -name "sky.fm-*" ')' -type l`"
8 if [ -z "$old" ];then echo >&2 "No existing symlinks found.";exit 1;fi
9 for site in di.fm sky.fm;do
10 newdashed="`wget -q -O - http://$site/|tr ' ' '\n' \
12 s{^.*"(?:http://www.'$site')?([^":]*(?<!_low)[.](?:pls|asx))".*$}{$1} or next;
13 m{^/aacplus/} and next;
18 if [ -z "$newdashed" ];then echo >&2 "Failed to download the new listing found.";exit 1;fi
20 if [ ! -x "$TARGET" ];then echo >&2 "Target engine $TARGET not found.";exit 1;fi
24 for pathdashed in $newdashed;do
25 test -L "$PREFIX$pathdashed" && continue
26 ln -s "$TARGET" "$PREFIX$pathdashed"
34 pathslashed="`basename "$0"|tr - /`"
36 stream="`lynx -source http://di.fm${pathslashed}|sed -n 's/^File1=//p'|tr -d '\r'`"
37 exec mplayer -ao oss:/dev/dsp -cache 128 "$stream" "$@"
40 streamlist="`lynx -source http://${pathslashed}|sed -n \
41 -e 's/^File[0-9]*=//p' \
42 -e 's#^.*"\(mms://[^"]*\)".*$#\1#p' \
44 for stream in $streamlist;do
45 # Using "set -e" here:
46 # mplayer rc 0 on failure to read the stream
48 # mplayer rc 1 on ctrl-c
49 ip="` echo "$stream"|sed -n 's#^http://\([^:/]*\).*$#\1#p'`"
51 port="`echo "$stream"|sed -n 's#^http://[^:/]*:\([0-9][0-9]*\).*$#\1#p'`"
53 echo >&2 "Checking $stream -> {$ip}:{$port} ..."
54 if ! nc -w 2 "$ip" "$port";then
55 echo >&2 "TIMEOUT: $stream"
59 mplayer -ao oss:/dev/dsp -cache 128 "$stream" "$@"