#!/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! # Amended by Nik Butler 2005 10 12 # Dropped creation of date in favour of downloading podcasts by title. # using wgets -N timestamp and -c Continue feature to grab the files. # wget knows what the filename is and if we have seen it or not # of course the above screws up if the file names change ! # also we accept 1 argument ... the count of the shows to download from the feed. # this stops the files going MAD trying to grab everything from the feed. # ive split the xsl files up to spot the title in the feed. # # Make script crontab friendly: cd $(dirname $0) rm current_shows temp_shows du -a | grep -i mp3 | awk '{FS=" "; print $2}' >temp_shows # Read the PodCast for Titles and Grab CurrentList into $title with wget while read podcast do echo $podcast title=$(wget -q $podcast -O - | xsltproc parse_enclosure_title.xsl - 2>/dev/null) # drop spaces and annoying characters from the name. title=${title//\ /_} title=${title//\'/} title=${title//\\/} title=${title//\//} # then create the directory. if ! test -d "$title" then mkdir $title fi # the file is the rss file from the site. and we seek order ! file=$(wget -q $podcast -O - | xsltproc parse_enclosure_url.xsl - 2>/dev/null )|| file=$(wget -q $podcast -O - | tr '\r' '\n' | tr \' \" | sed -n 's/.*url="\([^"]*\)".*/\1/p') # count the files we are downloading. fileCount=0 for url in $file do # increment by one and if a arguement was passed and # we match the amount of files downloaded drop out of this # go find more files other wise. # 2005 11 01 -- Lugradio seems to adda query string to the end of the url ... # so we want to strip it from the url before downloading the file. # #$filetmp = ${file//\\?.*/} infile=${url//\?[a-z]*/} # find the file name time.. outfile=$(echo $infile | awk 'BEGIN { FS = "/" } ; { print $(NF) }') if [ -n "$1" ] then if [ $fileCount -eq $1 ] then break fi fi echo "fetching $url" wget -c -N -P $title -O ./${title}/${outfile} "$infile" fileCount=$(($fileCount+1)) done done < bp.conf du -a | grep -i mp3 | awk '{FS=" "; print $2}' >>temp_shows datenow=$(date +%Y-%m-%d) sort temp_shows | uniq -u >> PodCasts-$datenow