#!/bin/sh -e
if [ $# != 1 ] ; then
	echo "Usage: $0 <wma file to convert>"
	exit 1
fi
set -x
OGG=`basename "$1" .wma | sed 's/[[:space:]]\+/_/g'`.ogg
if [ "$1" = "$OGG" ] ; then
	echo "$0: Seems $1 is not properly named file - expecting suffix .wma"
	exit 1
fi
WAV=`basename "$OGG" .ogg`.wav
# somehow mplayer decides himself about the WAV file anyway
WAV=audiodump.wav
mplayer -ao pcm -vo wav:output="$WAV" "$1"
oggenc -o "$OGG" "$WAV"
rm -f "$WAV"
