diff options
author | chris <root@telnet.shack> | 2010-12-28 21:15:54 +0100 |
---|---|---|
committer | tv <root@telnet.shack> | 2010-12-28 21:15:54 +0100 |
commit | d6d9deb733392e09b6b3f480eb6d5c90d2e973db (patch) | |
tree | ee9266b3b982be375abca4abb5cdc76ad1414bf6 /modules/stream | |
parent | ee245224a41f66c1d370e45d07a7cd2bed44ef57 (diff) |
added modules: shackstatus, stream
Diffstat (limited to 'modules/stream')
-rwxr-xr-x | modules/stream | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/stream b/modules/stream new file mode 100755 index 00000000..76e86317 --- /dev/null +++ b/modules/stream @@ -0,0 +1,50 @@ +#! /bin/sh +inputdir=$HOME/noise/streams +case "$1" in + (--help) + echo "play an audio stream" ;; + (*) + exec 2>&1 + ffs='xml' + + if test -z "$*" ; then + echo -e "\x1B[32m/stream off \x1B[33m- turn stream off\x1B[m" + for i in `ls $inputdir` ; do + filename="$inputdir/$i" + shortcut=`xmlstarlet sel -t -v /station/@shortcut "$inputdir/$i"` + title=`xmlstarlet sel -t -v /station/@title "$inputdir/$i"` + topic=`xmlstarlet sel -t -v /station/@topic "$inputdir/$i"` + stream=`xmlstarlet sel -t -v /station/@stream "$inputdir/$i"` + echo -e "\x1B[32m/stream $shortcut \x1B[33m- $title \x1B[35m$topic\x1B[m" + done + else if [ "$1" = "off" ]; then + [ ! -d /tmp/noise ] || ( echo "no directory /tmp/noise; aborting" ; exit 1 ) + [ -f /tmp/noise/stream.pid ] && ( kill ` cat /tmp/noise/stream.pid ` ) + [ -e /tmp/noise/stream.pid ] && rm /tmp/noise/stream.pid || ( echo "can't remove /tmp/noise/stream.pid; aborting" ; exit 1 ) + else + for i in `ls $inputdir` ; do + filename="$inputdir/$i" + shortcut=`xmlstarlet sel -t -v /station/@shortcut "$inputdir/$i"` + stream=`xmlstarlet sel -t -v /station/@stream "$inputdir/$i"` + if [ "$shortcut" == "$1" ]; then + [ ! -d /tmp/noise ] || ( umask 077 ; mkdir /tmp/noise ) || ( echo "can't create /tmp/noise; aborting" ; exit 1 ) + [ -f /tmp/noise/stream.pid ] && ( kill ` cat /tmp/noise/stream.pid ` ) + [ -e /tmp/noise/stream.pid ] && rm /tmp/noise/stream.pid || ( echo "can't remove /tmp/noise/stream.pid; aborting" ; exit 1 ) + mplayer -cache 2048 -quiet "$stream" & + ( umask 077 ; echo $! > /tmp/noise/stream.pid ) + break + fi + done || cat<<EOF +[33m\ +Keine Audiostreambeschreibung mit dem Namen + + [4m$1[;33m.EXT + +gefunden... am besten gleich anlegen: + + ssh shack@shack.shack:noise/streams/ + +folgende Dateiendungen werden erkannt: $ffs[m +EOF + fi fi +esac |