Skip to content

Instantly share code, notes, and snippets.

@Joopmicroop
Created November 8, 2018 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Joopmicroop/2a7f8ef5fa002aad243c4d3135d6958b to your computer and use it in GitHub Desktop.
Save Joopmicroop/2a7f8ef5fa002aad243c4d3135d6958b to your computer and use it in GitHub Desktop.
extract the rss feed from an itunes podcast url
#!/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