#!/bin/sh
#
# 20070221: Copies scrobbler.log back onto local fs copy, and invokes 
#	rockscrobber.pl on it to upload to my account

sdir=/mdata/ipod
#   Source directory where filesystem copy of rockbox device is.
mounted=/media/ipod
#   Directory where rockbox device is mounted
rockscrobbler=/home/mike/bin/rockscrobbler
#   Directory where scrobbler upload script is
scrobu=Zonkier
scrobp=*****
#   Username and password for last.fm. Don't use mine: They won't
#   work :)

if [ ! -d $sdir ]
then
  echo Cannot find source directory for music
  exit
fi

if [ -d $mounted ]
then
    if [ -f $mounted/.scrobbler.log ]
	then
	cp $mounted/.scrobbler.log $sdir/
	cd $rockscrobbler
	./rockscrobbler.pl \
	    -u $scrobu \
	    -p $scrobp \
	    -f $sdir/.scrobbler.log
    fi
	    
    cp $mounted/.rockbox/.glyphcache $sdir/.rockbox
    cp $mounted/.rockbox/.playlist_control $sdir/.rockbox
  
    cd $sdir
    rsync -arW --delete --stats --progress \
	--exclude=themes --exclude=backup . $mounted
else
  echo "Rockbox device not mounted"
fi
