Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Prints out URLs of items in Safari’s Reading List

View readinglisturls.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#!/usr/bin/env python
import plistlib
from shutil import copy
import subprocess
import os
from tempfile import gettempdir
import sys
import atexit
 
BOOKMARKS_PLIST = '~/Library/Safari/Bookmarks.plist'
bookmarksFile = os.path.expanduser(BOOKMARKS_PLIST)
 
# Make a copy of the bookmarks and convert it from a binary plist to text
tempDirectory = gettempdir()
copy(bookmarksFile, tempDirectory)
bookmarksFileCopy = os.path.join(tempDirectory, os.path.basename(bookmarksFile))
 
def removeTempFile():
os.remove(bookmarksFileCopy)
 
atexit.register(removeTempFile) # Delete the temp file when the script finishes
 
converted = subprocess.call(['plutil', '-convert', 'xml1', bookmarksFileCopy])
 
if converted != 0:
print "Couldn't convert bookmarks plist from xml format"
sys.exit(converted)
 
plist = plistlib.readPlist(bookmarksFileCopy)
# There should only be one Reading List item, so take the first one
readingList = [item for item in plist['Children'] if 'Title' in item and item['Title'] == 'com.apple.ReadingList'][0]
 
if 'Children' in readingList:
for item in readingList['Children']:
print item['URLString']
mcdado commented

It would be cool if there was an option (parameter?) that checks for the presence of DateLastView, so to only get unread items.

I would love to write a pull request here, but I have no knowledge of Python.

I second the above suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.