#!/bin/bash # By Linc 10/1/2004 # Find the latest script at http://linc.homeunix.org:8080/scripts/bashpodder # Last revision 10/23/2004 - The Lee Colleton/Wari Wahab/Dann Washko version. # 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! #VARS log=podcast.log conf=bp.conf playlist=podcast.m3u #usage function to print usage. usage() { builtin echo -e >&2 \ "usage: $0 [-p] [-l] [-h] \n -p make playlist \n -l keep log trimmed \n -h print this help" exit 1; } #getopts for playlist and log trimming. (JCE) while getopts plh opt do case "${opt}" in p) pl=set;; # playlist switch l) lt=set;; # log trim h) hlp=set;; # show help exit \?) usage # unknown flag exit 1;; esac done shift $(($OPTIND - 1)) #check for help flag. if [ "${hlp}" == "set" ]; then usage fi # Quickie change to make the script more cron friendly # Contributed by Wari Wahab workdir=`dirname ${0}` cd ${workdir} # datadir is the directory you want the audio files to be put into # I used a date string which will create a new directory every day # Changed to iso date format as suggested by Lee Colleton! # Updated to work on OSX by Dann Washko datadir=`date +%Y-%m-%d` # test for existance of data directory and create if not there if [ ! -d ${datadir} ] then mkdir ${datadir} fi touch ${log} # Read the conf file for rss feeds you wish to grab audio from # Used the sed line from Rodrigo Stulzer to better take care of # non-standard rss. (JCE) IFS_T=${IFS} IFS=' ' I=0 while read url do for url in $(wget -q ${url} -O - | sed 's/ /dev/null then wget -q -P ${datadir} ${url} echo ${url} >> ${log} fi #save all urls for uptodate log file #if -l flag is thrown if [ "${lt}" == "set" ]; then NEWLOG[${I}]=${url} ((I += 1)) fi done done < ${conf} IFS=${IFS_T} #Write a new log file containing only urls in current rss feeds. #if -l flag is thrown. if [ "${lt}" == "set" ]; then /bin/rm ${log} for urllog in "${NEWLOG[@]}"; do echo ${urllog} >> ${log} done fi # That's it! # Oh yeah, you probably want an m3u playlist (at least I do) # added a switch for making the play list (JCE) if [ "${pl}" == "set" ] ; then ls ${datadir} | grep -v m3u > ${datadir}/${playlist} fi