#!/bin/sh # Created by Lehman Black - http://dosnlinux.wordpress.com # podthingy - the podcatching thingy # name suggestions welcome ;) CWD=`pwd` # TODO: make an "unlistened" folder # TODO: integrate into SVN repo # podcasts should be stored in separate folders under $PODCAST_ROOT # each podcast directory should have a *.list and *.info file # sample info file #PODCAST="The Java Posse" #TOPIC="Java news" #HOMEPAGE="http://javaposse.com" #FEED="http://feeds.feedburner.com/javaposse" #LICENSE="Creative Commons" #ALBUM="The Java Posse" #ARTIST="Tor Norbye, Carl Quinn, Joe Nuxoll, Dick Wall" #GENRE="Podcast" # end info file PODCAST_ROOT=$HOME # make sure it works on folders only for PODCAST in $PODCAST_ROOT/*/ do if ! [ -f $PODCAST/*.info ] then # skip if this is not a podcast directory continue fi INFO_FILE=$PODCAST/*.info LIST_FILE=$PODCAST/*.list PODNAME=`grep PODCAST $INFO_FILE | cut -d \" -f2` echo "Podcast: $PODNAME" echo # preserve origional *.list until everything's finished downloading TMP=`mktemp -t podcast.XXXXXX` cat $LIST_FILE > $TMP echo -e "\tScanning feed for new episodes..." echo FEED=`grep FEED $INFO_FILE | cut -d \" -f2` FEED_ITEMS=`wget -q -O - $FEED | \ awk -F '<' '/url=/{print $NF}' | \ grep 'url=' | \ sed -e 's/.*url=\"//' \ -e 's/\".*//'` NEW_ITEMS="" for NEW in $FEED_ITEMS do if ! ( grep -q $NEW $LIST_FILE ) then echo -e "\tNEW: $NEW" NEW_ITEMS="$NEW_ITEMS $NEW" fi done # TODO count number of new episodes # skip if there are no podcasts to download if [ -z `echo $NEW_ITEMS | tr -d '[:space:]'` ] then echo "Podcast up to date" echo rm $TMP continue fi echo # download the new episodes for EPISODE in $NEW_ITEMS do echo -ne "\tDownloading $EPISODE... " wget --random-wait -q -c $EPISODE -P $PODCAST echo $EPISODE >> $TMP echo "Done." done # put the most recent podcast at the beginning -- hopefully echo -e "\tUpdating list file" sort -r $TMP > $LIST_FILE rm $TMP echo echo "Podcast up to date" echo done