#!/bin/sh
#CCCP script that watches a query and downloads all matches

#If you want more precis query edit the regexp

#the actual script is in dlrobot.pl 


case $# in
0) echo "Usage: " `basename $0` "<artist name>";
	exit 255;
esac 

searchquery="*$1*1"

cccp -L > /dev/null
if [ $? -ne "0" ]
then
	echo "Please connect to a hub first"
	exit
fi

cccp -r "DONE"

while [ 1 ]
do
cccp -N -s "$searchquery" | awk -F\| '{if(match($2,/mp3$|pdf$|zip$/))print $0}' | perl dlrobot.pl
sleep 60
done
