#!/bin/sh
#CCCP script by hampa@chello.se
#add a file to a segment group
#usage: cccp -s somemovie.mpg | ./seg_add gdlid 
#you can see the group id by doing a cccp -gl

#/GDLNEW gdlid|filesize|filename
#/GDLADD gdlid|nickname|remotefilename|remotefilesize 

#cccp -gn gid1 movie.mpg 526441776

if [ $# -eq 0 ]
then
	echo "usage: cccp -s filename | $0 gdlid"
	exit 1;
fi
glid=$1

while read -r line
do
echo $line | awk -F\| '{printf("'$glid' \"%s\" \"%s\" %s\n", $1, $2, $3)}' | xargs -exec cccp -ga  
done 
