#!/bin/sh

if [ "x$1" = "x" ]; then
	APP=org.kde.amarok
else
	APP=$1
fi; 

if [ "x$2" = "x" ]; then
	FILTER="title:"
else
	FILTER=$2
fi; 

LENGTH=`qdbus $APP /TrackList GetLength`

I=0

while [ $I -lt $LENGTH ]
do
   T=`qdbus $APP /TrackList GetMetadata $i |grep $FILTER |cut -f 2 -d ":"|tr -s "," " "`
   ni=`expr $i + 1`  
   echo "$ni.$T,"
   
   I=`expr $I + 1`
done
