Last active
June 25, 2019 07:29
-
-
Save max-arnold/c2456e1cbb79789d657b4ee178c71a5e to your computer and use it in GitHub Desktop.
Export Safari Reading List to CSV
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
#!/usr/bin/env python3 | |
# A script to export (backup) Safari Reading List | |
import os | |
import plistlib | |
with open(os.path.expanduser('~/Library/Safari/Bookmarks.plist'), 'rb') as fp: | |
plist = plistlib.load(fp) | |
bookmarks = [ | |
ch['Children'] for ch in plist['Children'] | |
if ch.get('Title', None) == 'com.apple.ReadingList' | |
][0] | |
urls = ( | |
( | |
b['ReadingList']['DateAdded'].strftime('%Y-%m-%d %H:%M:%S'), | |
b['URLString'], | |
'"' + b['URIDictionary']['title'] + '"' | |
) for b in bookmarks | |
) | |
for u in sorted(urls): | |
print(', '.join(u)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment