#!/bin/sh
#
# amarok-logger: keep a log of tracks played in amarok
#
# usage: put this in ~/.kde/share/apps/amarok/scripts/songchange/songchange
# and create songchange.spec in the same directory with contents:
#   name = songchange
#   type = generic
# then select this script in amarok's script manager and hit 'Run'
#
# source: http://impressive.net/people/gerald/2009/01/amarok-logger
#
# Gerald Oskoboiny, 13 Jan 2009
#
# $Id: amarok-logger,v 1.1 2009/01/14 01:55:30 gerald Exp $
#

while read line; do
    if [ trackChange = "$line" ]; then
	date=`/bin/date +"%Y-%m-%d %T"`
	filename=`dcop amarok player encodedURL`
	artist=`dcop amarok player artist`
	album=`dcop amarok player album`
	title=`dcop amarok player title`
	length=`dcop amarok player trackTotalTime`
	echo "$date $filename 0 ${length}000ms $artist - $album - $title" \
	    >> $HOME/misc/mm/whatson
    fi
done

# this log format is suboptimal, I'm using it for backwards compatibility
# with a decade's worth of logged data in other players (audacious, xmms)

