bashpodder for C2-00


#!/bin/bash
# By Linc 10/1/2004
# Find the latest script at http://lincgeek.org/bashpodder
# Revision 1.21 12/04/2008 - 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
# and post your changes to the forum at http://lincgeek.org/lincware
# I'd appreciate it!

# Make script crontab friendly:
cd $(dirname $0)

# datadir is the directory you want podcasts saved to:
datadir=$(date +%Y-%m-%d)
datadir=temp

# create datadir if necessary:
mkdir -p $datadir

# Delete any temp file:
rm -f temp.log

# Read the bp.conf file and wget any url not already in the podcast.log file:
while read podcast
do
# skip any comment lines and trailers
echo $podcast | grep -q \# && continue
echo $podcast | grep -q TimosMovieTrailers && continue
echo $podcast | grep -q trailers && continue

file=$(xsltproc parse_enclosure.xsl $podcast 2> /dev/null || wget -q $podcast -O - | tr '\r' '\n' | tr \' \" | sed -n 's/.*url="\([^"]*\)".*/\1/p')
echo $file > list_of_url

# do last two episodes
file=`awk '{print $1" "$2" "$3}' list_of_url`
# awk '{print $1" "$2" "$3}' list_of_url
# do last episode only
# file=`awk '{print $1}' list_of_url`



for url in $file
do
echo $url >> temp.log
echo $url
echo $podcast > /tmp/current-url-bp.log
if ! grep "$url" podcast.log > /dev/null
then
wget -t 10 -U BashPodder -c -q -O $datadir/$(echo "$url" | awk -F'/' {'print $NF'} | awk -F'=' {'print $NF'} | awk -F'?' {'print $1'}) "$url"
if grep marketplace /tmp/current-url-bp.log > /dev/null
then
echo "id3tag is being written " $url
id3v2 -A "APM Marketplace" $datadir/$(echo "$url" | awk -F'/' {'print $NF'} | awk -F'=' {'print $NF'} | awk -F'?' {'print $1'})
fi
if grep "id=35" /tmp/current-url-bp.log > /dev/null
then
echo "id3tag is being written " $url
id3v2 -A "Wait Wait... Don't Tell Me!" $datadir/$(echo "$url" | awk -F'/' {'print $NF'} | awk -F'=' {'print $NF'} | awk -F'?' {'print $1'})
fi
fi
done
done < bp.conf # Move dynamically created log file to permanent log file: cat podcast.log >> temp.log
sort temp.log | uniq > podcast.log
rm temp.log
# Create an m3u playlist:
#ls $datadir | grep -v m3u > $datadir/podcast.m3u



http://downloads.bbc.co.uk/podcasts/radio4/fricomedy/rss.xml
http://www.npr.org/rss/podcast.php?id=35
#http://feeds.feedburner.com/cnet/buzzoutloud?format=xml
http://www.marketplace.org/shows/85/podcast.xml
#http://feeds.feedburner.com/freakonomicsradio?format=xml
http://downloads.bbc.co.uk/podcasts/radio4/radioplay/rss.xml