Update: I’ve released an open source version of this script in php. Be sure to try out the fully functioning demo.
I often find myself discovering podcasts that are only provided as an iTunes link. Content providers risk excluding a significant number of users by not providing a standard link to the original podcast feed.
The following bash script (itx.sh) will extract the podcast’s feed url so that you may subscribe using an rss client of your choice:
#!/bin/sh
# extract the podcast id from the first argument
id=$(echo $1 | sed -r 's/^(http.+\/id([0-9]+)|([0-9]+)$).*/\2\3/')
# the podcast id was not supplied if $id isn't an integer
c=$(echo $id | tr -d 0-9)
if [ $# == 0 ] || [ -n "${c}" ]; then
echo The podcast ID must be in one of the following formats:
echo "- itx https://itunes.apple.com/gb/podcast/above-beyond-group-therapy/id286889904"
echo "- itx 286889904"
return
fi
# curl a request to iTunes and extract the feedURL attribute
url="https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/com.apple.jingle.app.finance.DirectAction/subscribePodcast?id=${id}&wasWarnedAboutPodcasts=true"
feedUrl=$(curl -s -A "iTunes/9.1.1" "${url}" | grep "feedURL" | sed -r "s/.+<string>([^<]+).+/\1/")
# return the source podcast url if it was found
if [ -n "${feedUrl}" ]; then
echo $feedUrl
fi
Reference: get the latest podcasts from itunes store with link by RSS, JSON or something