audio.in 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #! /bin/sh
  2. #
  3. # Written by Pavel Machek
  4. # CDDB support by Adam Byrtek
  5. #
  6. # (C) 2000 The Free Software Foundation.
  7. #
  8. set -e
  9. CDDB_SERVER="http://freedb.freedb.org"
  10. CDDB_HANDSHAKE="hello=user+localhost+mc+1.0&proto=1"
  11. CDDB_TIMEOUT=20 # in seconds
  12. audiofs_list()
  13. {
  14. DATE=`date +"%b %d %H:%M"`
  15. echo "-r--r--r-- 1 0 0 0 $DATE CDDB"
  16. cdparanoia -Q -d "$1" 2>&1 | grep '^[ 0-9][ 0-9][ 0-9]\.' | while read A B C
  17. do
  18. A=`echo "$A" | sed -e 's/\.//' -e 's/^\(.\)$/0\1/'`
  19. SIZE=`expr 44 + $B \* 2352`
  20. echo "-r--r--r-- 1 0 0 $SIZE $DATE track-${A}.wav"
  21. done
  22. }
  23. audiofs_copyout()
  24. {
  25. if [ x"$2" = x"CDDB" ]; then
  26. DISCID=`cd-discid "$1" | tr " " "+"`
  27. if [ -z "$DISCID" ]; then
  28. exit 1
  29. fi
  30. RESPONSE=`wget -q -T $CDDB_TIMEOUT -O - "$CDDB_SERVER/~cddb/cddb.cgi?cmd=cddb+query+$DISCID&$CDDB_HANDSHAKE" | tee "$3" | @AWK@ '/^200/ { print $2,$3; }'`
  31. wget -q -T $CDDB_TIMEOUT -O - "$CDDB_SERVER/~cddb/cddb.cgi?cmd=cddb+read+$RESPONSE&$CDDB_HANDSHAKE" | grep -v "^#" >> "$3"
  32. else
  33. TRACK=`echo "$2" | sed 's/track-0*//' | sed 's/\.wav//'`
  34. cdparanoia -q -d "$1" "$TRACK" "$3" >/dev/null
  35. fi
  36. }
  37. if [ ! -b "$2" ]
  38. then
  39. BASE="/dev/cdrom"
  40. else
  41. BASE="$2"
  42. fi
  43. case "$1" in
  44. list) audiofs_list "$BASE"; exit 0;;
  45. copyout) audiofs_copyout "$BASE" "$3" "$4"; exit 0;;
  46. esac
  47. exit 1