I was wanting to try out Overcast on iOS and needed a way to export my subscriptions. Unfortunately the Apple Podcasts app does not support exporting your subscriptions as an OPML feed.
I found this on the Apple Stack Exchange site which let me create an OPML file from the subscriptions database created by the Apple Podcasts app. This will only work for you on macOS as it’s not easy to get access to the database used by the iOS version of the app.
#!/bin/bash
sql() {
sqlite3 "${HOME}/Library/Group Containers/"*.groups.com.apple.podcasts/Documents/MTLibrary.sqlite "select ${1} from ZMTPODCAST ${2:+"where ${2} = '${3}'"};" |\
sed -e 's/&/\&/g' \
-e 's/</\</g' \
-e 's/>/\>/g' \
-e "s/'/\'/g"
}
opml_export=${HOME}/Desktop/podcasts.opml
cat > ${opml_export} << HEAD
<?xml version="1.0" encoding="utf-8"?>
<opml version="1.0">
<head><title>Podcast subscriptions</title></head>
<body>
<outline text="feeds">
HEAD
sql ZUUID | while read -r uuid ; do
feed_url=$(sql ZFEEDURL ZUUID "${uuid}")
home_url=$(sql ZWEBPAGEURL ZUUID "${uuid}")
title=$(sql ZTITLE ZUUID "${uuid}")
cat <<EOT
<outline type="rss" text="${title}" title="${title}" xmlUrl="${feed_url}" htmlUrl="${home_url}" />
EOT
done >> ${opml_export}
cat >> ${opml_export} << TAIL
</outline>
</body>
</opml>
TAIL