Created
November 17, 2015 18:45
-
-
Save tjluoma/bdb24db6642107a643ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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