#!/bin/bash
#
# Downloads all newsgroups whose target areas belong to the
# given context.
#
#

if [ ! $1 ] ; then
	echo "Usage: $0 [context id]"
	exit
fi

mysql --skip-column-names --execute="USE pimppa; SELECT DISTINCT g_name FROM p_groups,p_areas WHERE g_dest=area_id and area_context=$1 ORDER BY g_name;" | while read GROUPNAME; do
	pleech -i -v -g %$GROUPNAME%
done


