# # This script does a "find" for mp3/mp2 files on a server and # makes a http playlist of them for playing somewhere else. # # Copyright (C) 1992,2003 Bisqwit (http://iki.fi/bisqwit/) # # Where to go with your SSH sshtarget="bisqwit@bisqwit.iki.fi" # Which directory to watch dir="/WWW/kala/jap" # Where the files appear to http users baseurl="http://bisqwit.iki.fi/kala/jap/" # Where to store the playlist tmpf=/tmp/makelist.tmp # Code begins. if test ! -f "$tmpf"; then printf '\33[1;37mGenerating playlist...\33[m\n' ssh $sshtarget "cd $dir;find -follow"|cut -c3-|grep 'mp[23]$'| \ while read s; do echo "$baseurl""$s"; done >"$tmpf" fi filecount="`wc -l <"$tmpf"|tr -d \ `" printf '\33[1;37mPlaylist contains %d files. Playing...\33[m\n' $filecount while true;do fn="$(tail +$[RANDOM%$filecount] < "$tmpf"|head -n1)" printf 'Now playing: \33[1;37m%s\33[m\n' "$fn" mpg123 -qv "$fn" echo done # This is shorter, but doesn't tell what we're playing #mpg123 -zqvvvv@- < "$tmpf"