#!/bin/bash

# Modified by John Jensen 2005.01.23, to split into "check" and "fetch".
# The idea being to run "check.bash", pause, examine the "new_mp3"
# file and delete anything I don't really want before I invoke the
# "fetch.bash" file to go out and get them.  The "fetch script"
# also has changes to support Evil Genius style torrent mp3s.

# By Linc 10/1/2004
# Find the latest script at http://linc.homeunix.org:8080/scripts/bashpodder
# Last revision 12/14/2004 - Many Contributers!
# If you use this and have made improvements or have comments
# drop me an email at linc dot fessenden at gmail dot com
# I'd appreciate it!

# Delete any "new" file:

rm -f new_mp3

# Read the check.conf file and wget any url not already in the old_mp3 file:

while read podcast
	do
	file=$(wget -q $podcast -O - | tr '\r' '\n' | tr \' \" | sed -n 's/.*url="\([^"]*\)".*/\1/p')
	for url in $file
		do
		if ! grep "$url" old_mp3 > /dev/null
		then
			echo $url >> new_mp3
		fi
		done
	done < check.conf

# Go ahead and add these to the old_mp3 file, even if they might not
# ever be fetched

cat new_mp3 >> old_mp3

# At this point we have a "new_mp3" file to be reviewed befor invoking
# the second script: fetch.bash
