Exporting podcasts from iOS app as OPML

I have finally decided to switch from the Apple Podcast app to Overcast, but I cannot find a way to move my subscriptions. A (similar question) was asked a while ago, but iTunes has changed since then, and the new MacOS app doesn't have those menus. So, I was wondering if anyone knows another way to get an OPML file.


Solution 1:

The Podcasts app appears to store its data inside a sqlite database. Using the information inside we can create an OPML file that Overcast (or any good podcast app) will accept.

Here's a script that I made that will create the OPML file:

#!/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/</\&lt;/g' \
            -e 's/>/\&lgt;/g' \
            -e "s/'/\&apos;/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

For people unfamiliar with how to run scripts on the command line, it's easy:

  • copy the entire text from the gray box above
  • open the Terminal app
  • at your Terminal prompt, type:
    • pbpaste > export_podcasts.sh, pasting the text into an appropriately named file
    • hit return, then type:
    • chmod u+x export_podcasts.sh, making your file executable
    • hit return, then type:
    • ./export_podcasts.sh, executing your script

This will create podcasts.opml on your desktop.

To get this file to your iPhone, you can use AirDrop or iCloud Drive:

AirDrop - Make sure your Mac and iPhone have AirDrop enabled, you can right click on the file, then Share > AirDrop, and tap the icon showing your iPhone's avatar and phone name. This should automatically open the file on your iPhone and allow you to start the import in Overcast.

iCloud Drive - If iCloud Drive is set up on your Mac and iPhone, you can move podcasts.opml into an iCloud Drive folder on your Mac, and then open the file from your Files app on iPhone. It should then prompt you to "Open with Overcast", which should then import the podcasts in the file.