#!/bin/bash

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`
for (( i=0; i<$length; i++ ))
do
   T=`qdbus $APP /TrackList GetMetadata $i |grep $FILTER |cut -f 2 -d ":"|tr -s "," " "`
   ni=`expr $i + 1`  
   echo "$ni.$T,"
done
