#!/bin/sh # update-downcoder-metadata -- keeps the metadata on all downcoders in sync # # Copyright © 2000-2006 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. No representations are made about the suitability of this # software for any purpose. It is provided "as is" without express or # implied warranty. # # Created: 20-Jul-2000 progname=update-downcoder-metadata stream_source="$1" metadata_url_1=http://gronk.jwz.org/jwz/gronk/current.txt metadata_url_2=http://cerebellum.dnalounge.com/metadata.txt dst_urls="http://cerebrum.dnalounge.com:8000/live/128" # http://cerebrum.dnalounge.com:8000/live/96 # http://cerebrum.dnalounge.com:8000/live/64 # http://cerebrum.dnalounge.com:8000/live/48 # http://cerebrum.dnalounge.com:8000/live/32 # http://cerebrum.dnalounge.com:8000/live/24" # pull the password out of the icecast config icecast_conf=/usr/local/icecast/conf/icecast.conf if [ -f $icecast_conf ]; then passwd=`sed -n 's/^[ \t]*encoder_password[ \t][ \t]*\(.*\)$/\1/p' \ $icecast_conf` else # icecast_conf=/usr/local/icecast/etc/icecast.xml icecast_conf=/etc/icecast.xml passwd=`sed -n 's/^.*\([^<>]*\)<.*$/\1/p' \ $icecast_conf` fi poll_delay=15 extra_lag=15 gronk_p=0 if ( echo "$stream_source" | fgrep gronk.jwz.org >/dev/null ); then metadata_url="$metadata_url_1" else metadata_url="$metadata_url_2" fi PATH=/usr/local/bin:$PATH PATH=/home/jwz/src/icecast:$PATH export PATH update_once() { data=`wget -t1 -T5 -qO- $metadata_url` if [ "$data" = "" ]; then echo "$0: no metadata" >&2 else # convert "artist \t album \t track \t year" to "track - artist" # data=`echo "$data" | sed 's/^\(.*\) \(.*\) \(.*\) \(.*\)/\3 - \1/'` # convert "artist \t album \t track \t year" to "artist -- track" data=`echo "$data" | sed 's/^\(.*\) \(.*\) \(.*\) \(.*\)/\1 -- \3/'` sleep $extra_lag for url in $dst_urls ; do write-metadata.pl "$url" "$passwd" "$data" done fi sleep $poll_delay } update_loop() { while true ; do update_once done } # log all stdout/stderr text to syslog log_lines() { while read line ; do logger -st "$progname" "$line" done } echo "started at `date`" | log_lines update_loop 2>&1 | log_lines exit 0