#!/bin/bash # By Linc 10/1/2004 # Find the latest script at http://linc.homeunix.org:8080/scripts/bashpodder # Last revision 07/01/2005 - 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! # Changes by Chess Griffin 12/09/2005 # Make script crontab friendly: cd $(dirname $0) # Use an incoming folder to hold feeds prior to editing the file name # from James Stone echo "Creating temp folders..." incoming="incoming" rm -rf $incoming mkdir $incoming # Delete any temp file: rm -f temp.log # If this is the first time running, create the podcast.log # from Scott Maxwell if ! [ -e podcast.log ] then echo "Creating podcast.log file..." touch podcast.log fi # Read the bp.conf file and wget any url not already in the podcast.log file: while read podcast datadir do # Skip lines beginning with '#' as comment lines - from Rick Slater if echo $podcast | grep '^#' > /dev/null then continue fi # Check to make sure datadir is listed on each line; if not, print message. Or, comment out the exit 1 line to have bashpodder quit if datadir not there. if test ! $datadir then echo "No feed directory specified in bp.conf for the $podcast feed. Files will be saved in temporary 'incoming' directory but will deleted next time Bashpodder is run. Please move those files and be sure to edit bp.conf and name a directory for this feed." #exit 1; fi # Check for and create datadir if necessary: # (Uses Tony Whitmore's addition to bp.conf where # name of directory comes after feed, e.g., # http://www.lugradio.org/episodes.rss LUGRadio) if test ! -d $datadir then echo "Creating $datadir directory to store feeds..." mkdir $datadir fi file=$(wget -q $podcast -O - | xsltproc parse_enclosure.xsl - 2> /dev/null) || file=$(wget -q $podcast -O - | tr '\r' '\n' | tr \' \" | sed -n 's/.*url="\([^"]*\)".*/\1/p') for url in $file do #the realurl fix for dynamically generated feeds (from Huw #Lynes and James Stone) realurl=`curl -s -I -L -w %{url_effective} --url $url | tail -n 1` #echo "Fetching $realurl..." #short url (i.e. filename!) from James Stone urlss=`echo $realurl|awk -F / '{print $NF}'` urls=`echo $urlss|awk -F ? '{print $1}'` #echo $urlss|awk -F ? '{print $1}' if ! grep "$urls" podcast.log > /dev/null then # added Christian Daven's wget switches echo "Fetching $realurl..." wget -q -c -T 2 -P $incoming "$realurl" #fix for ?podcast end to recent lugradio feeds #from James Stone mv $incoming/$urls* $datadir/$urls echo $urls >> temp.log fi done # Create an m3u playlist: echo "Creating $datadir m3u playlist..." ls $datadir | grep -v m3u > $datadir/podcast.m3u done < bp.conf # Move dynamically created log file to permanent log file: echo "Cleaning up..." cat podcast.log >> temp.log sort temp.log | uniq > podcast.log rm temp.log echo "Done."