#!/bin/sh

# lugradio mirror script. Assumes you are mirroring an entire season.
# This part does the actual registering of the files on the mirror
# system.

source config.sh

cp files files.added

for a in $(diff files newfiles | grep "^>" | grep -v "html" | grep "lugradio-" | sed -e 's#> audio\.lugradio\.org/##'); do
	if [ -f audio.lugradio.org/${a} ]; then
		echo "${url}/${a}"
		res=`GET http://www.lugradio.org/addmirror/${mirrorurl}/${a}`
		if [ "$res" == "200: OK" ]; then
			echo "$res"
			echo "audio.lugradio.org/${a}" >> files.added
		else
			echo "FAIL: ${a}"
		fi
	fi
done

sort -n files.added > files
rm -f files.added


