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')?([^":]*(?<!_low)[.](?:pls|asx))".*$}{$1} or next;
+ m{^/aacplus/} and next;
+ tr{/}{-};
+ print;
+ ' \
+ `"
+ 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
+ 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'`"
# 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