Created
May 11, 2020 01:56
-
-
Save jaronheard/f2673a01d6b1f992de55c764f8269a45 to your computer and use it in GitHub Desktop.
Bash script to export Podcasts from Mac OS Catalina to OPML
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 | |
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/>/\&lgt;/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From https://apple.stackexchange.com/questions/374696/exporting-podcasts-from-ios-app-as-opml
Thanks!