#!/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! # Revision on 07/03/2005 By Travis Nickles # BashPodder now checks the filename of a desinated download, not the full url, # to determine whether a file has been previously downloaded. # This will help avoid problems with feeds with updates mirrors, like LugRadio, # so BashPodder does not download a previously downloaded file again, # but this will cause a problem when different files use the same filename. # The full url is still stored in the podcast.log file. # Make script crontab friendly: cd $(dirname $0) # datadir is the directory you want podcasts saved to: datadir=$(date +%Y-%m-%d) # Check for and create datadir if necessary: if test ! -d $datadir then mkdir $datadir fi # 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 file=$(wget -q $podcast -O - | xsltproc parse_enclosure.xsl - 2> /dev/null) || file=$(wget -q $podcast -O - | tr '\r' '\n' | tr \' \" | sed -n 's/.*enclosure.*url="\([^"]*\)".*/\1/p') for url in $file do filename=$(echo $url | sed -n 's\.*/\\p') if ! grep "$filename" podcast.log > /dev/null then wget -q -P $datadir "$url" && echo $url >> temp.log 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 # Discard empty podcast files / data directories (Contributer Paul Laws) # http://linc.homeunix.org:8080/scripts/bashpodder/user_contributed/paul_laws/ [ -s $datadir/podcast.m3u ] || rm $datadir/podcast.m3u rmdir $datadir 2>/dev/null