Skip to content

Instantly share code, notes, and snippets.

@mappu
Created October 13, 2013 03:43
Show Gist options
  • Save mappu/6957919 to your computer and use it in GitHub Desktop.
Save mappu/6957919 to your computer and use it in GitHub Desktop.
#!/bin/bash
# heavensgate.sh
# Download all current available heavensgate.co.uk podcast episodes.
XMLSRC="http://audiops.net/_promo/heavensgate_facebook/list_audioplayer.php"
BASEDL="http://audiops.net/_promo/heavensgate_facebook/"
OUTDIR="`dirname $0`/heavensgate"
mkdir -p "$OUTDIR"
# Get list
BODY=`curl -s "$XMLSRC"`
if [ $? -ne 0 ] ; then
exit 1
fi
URLS=`echo "$BODY" | grep location | sed -re 's/^[^>]+>([^<]+)<.*$/\1/'`
# Download missing files
while read -r url ; do
BASENAME=`basename "$url"`
if [ ! -f "$OUTDIR/$BASENAME" ] ; then
wget -O "$OUTDIR/$BASENAME" "${BASEDL}${url}"
chmod 644 "$OUTDIR/$BASENAME"
fi
done <<< "$URLS"
# Tidy up
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment