MacOS – How to get Reading List items as links

icloudmacosreading-listsafari

I just have a billion items in Safari's reading list and I would like the links to all of them.

Is there a way to get all of the items in your reading list as links (maybe in a text document)?

Best Answer

I whipped up a Python script to read the plist file referenced in the question patrix mentioned in the comments.

#!/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']

Copy and paste that into a file, name it something like readinglisturls.py. Then make it executable by running chmod +x readinglisturls.py in the Terminal. Then you can run it in the Terminal and it will print out any Reading List URLs. If you want the URLs in a file, you can redirect the output to a file by running /path/to/readinglisturls.py > myfile.txt in the Terminal.