#!/bin/bash

#
# Remove pages from Emily Dickinson categories
#
# Copyright (C) 2006, GrafZahl (en.wikisource.org user)
#
# Licence: GPLv2
#
# Give throttle as argument
#

# Category tree file was generated with category.py and then junk-chopped with
# sed(1)

PYTHON=/usr/bin/python
CATSCRIPT=category.py
TREEFILE=dickinson.tree

#Check throttle sanity

THROTTLE=$1

if [ -z $THROTTLE ]; then
	echo "(EEE) Please give a throttle as first argument";
	exit 1;
fi;

if [ $THROTTLE -lt 5 ]; then
	echo "(EEE) Throttle should be at least 5 seconds";
	exit 1;
fi;

while read category; do
	# Sleep just to be sure
	echo "(III) Sleeping for $THROTTLE seconds";
	sleep $THROTTLE;
	echo "(III) Removing Category $category from all pages";
	$PYTHON $CATSCRIPT remove -from:"$category" -batch -putthrottle:$THROTTLE;
done < $TREEFILE