Skip to content

Instantly share code, notes, and snippets.

@tjluoma
Created November 17, 2015 18:45
Show Gist options
  • Select an option

  • Save tjluoma/bdb24db6642107a643ee to your computer and use it in GitHub Desktop.

Select an option

Save tjluoma/bdb24db6642107a643ee to your computer and use it in GitHub Desktop.
#!/bin/zsh -f
# Purpose: Download all .mp3 episodes of a podcast
#
# From: Timothy J. Luoma
# Mail: luomat at gmail dot com
# Date: 2015-11-17
NAME="$0:t:r"
if [ -e "$HOME/.path" ]
then
source "$HOME/.path"
else
PATH='/usr/local/scripts:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin'
fi
FEED='http://arkiv.radio24syv.dk/audiopodcast/channel/12391837'
TITLE=`curl -sfL "$FEED" | fgrep '<title>' | head -1 | sed 's#.*<title>##g; s#</title>.*##g'`
SAVE_TO="$HOME/Music/Podcasts/$TITLE"
[[ ! -d "$SAVE_TO" ]] && mkdir -p "$SAVE_TO"
cd "$SAVE_TO" || cd
echo "$NAME: saving to $PWD:"
curl -sfL "$FEED" \
| tr -s '"' '\012' \
| egrep '^http.*\.mp3' \
| while read line
do
URL="$line"
FILENAME="$line:t"
echo "$NAME: Saving $URL to $PWD/$FILENAME:"
if [[ -e "$FILENAME" ]]
then
curl --continue-at - --progress-bar --fail --location --output "$FILENAME" "$URL" 2>/dev/null
case "$?" in
416)
echo "$NAME: Already have $FILENAME"
;;
esac
else
curl --progress-bar --fail --location --output "$FILENAME" "$URL"
fi
done
exit 0
#EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment