Created
November 8, 2018 13:20
-
-
Save Joopmicroop/2a7f8ef5fa002aad243c4d3135d6958b to your computer and use it in GitHub Desktop.
extract the rss feed from an itunes podcast url
This file contains 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/bash | |
#URL="https://itunes.apple.com/us/podcast/surprisingly-awesome/id1053898" | |
isValidURLRegex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]' | |
if [[ $1 =~ $isValidURLRegex ]] | |
then | |
# extract id from url | |
ID=$(echo $1 | grep -oP 'id\d+' | grep -oP '\d+') | |
else | |
ID=$1 | |
fi | |
FEED=$(curl -s "http://itunes.apple.com/lookup?id=$ID" | grep -oP '"feedUrl":"(.*?)"' | cut -d"\"" -f4) | |
echo "$FEED" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment