#!/bin/bash # Originally by Linc 10/1/2004 # Find the original script at http://linc.homeunix.org:8080/scripts/bashpodder # # Modified by James Rayner, iphitus@gmail.com # www.iphitus.tk # # NOTE: Location of config and log files has moved to # ~/.bashpodder/.temp.log # ~/.bashpodder/.podcast.log # ~/.bashpodder/bpd.conf # ~/.bashpodder/bp.conf # # Make script crontab friendly: cd $(dirname $0) # datadir is the directory you want podcasts saved to datadir=/home/iphitus/Multimedia/Podcasts/$(date +%Y-%m-%d)/ confdir=${HOME}/.bashpodder/ pyconf=.bashpodder # Check for and create datadir if necessary: if test ! -d $datadir then mkdir $datadir fi # Check for bashpodder config dir if test ! -d $confdir then mkdir $confdir fi # Put my ugly script into directory :) echo "#! /usr/bin/env python from sys import argv from os import getenv podcasts = open(getenv(\"HOME\")+\"/\"+\"$pyconf\"+\"/bp.conf\") podcastdirs = open(getenv(\"HOME\")+\"/\"+\"$pyconf\"+\"/bpd.conf\") dirs = podcastdirs.readlines() casts = podcasts.readlines() podcasts.close() podcastdirs.close() for cast in casts: if cast.rstrip() == argv[1]: print dirs[casts.index(cast)]" > ${confdir}/bpdir.py # Delete any temp file: rm -f ${confdir}/.temp.log # Read the bp.conf file and wget any url not already in the podcast.log file: while read podcast do poddir=`python ${confdir}/bpdir.py $podcast` if test ! -d "${datadir}${poddir}" then mkdir "${datadir}${poddir}" fi file=$(wget -q $podcast -O - | tr '\r' '\n' | tr \' \" | sed -n 's/.*url="\([^"]*\)".*/\1/p') for url in $file do echo $url >> ${confdir}/.temp.log if ! grep "$url" ${confdir}.podcast.log > /dev/null then wget -nc -P "${datadir}${poddir}" "$url" fi done done < ${confdir}/bp.conf # Move dynamically created log file to permanent log file: mv ${confdir}/.temp.log ${confdir}/.podcast.log # ok, i broke the original one :p now i use find #ls $datadir | grep -v m3u > $datadir/podcast.m3u pushd ${datadir} > /dev/null find . -iname "*mp3" > $datadir/podcast.m3u find . -iname "*ogg" > $datadir/podcast.m3u pushd > /dev/null # Clean out my script rm ${confdir}/bpdir.py