#!/bin/sh
#CCCP script by hampa@chello.se
#this script will first add a new GDL then
#add files to that GDL

#usage: cccp -s somefile | ./seg_new_add

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

#cccp -gn g id1 movie.mpg 526441776


gid=`date +%s`
i=0;

while read -r line
do
if [ $i -eq 0 ]
then
	echo $line | awk -F\| '{printf("%i \"%s\" \"%s\"\n", '$gid', $2, $3)}' | xargs -exec cccp -gn 
	i=1
fi
echo $line | awk -F\| '{printf("'$gid' \"%s\" \"%s\" %s\n", $1, $2, $3)}' | xargs -exec cccp -ga  
done 
