Exporting Safari Reading List to Pinboard and/or Markdown

[Tweet : nvALT]

I’ve heard from a few people that this script might be useful to them. I’ve also created an “app” version of it you can run, but it still takes a wee bit of command line setup. It’s pretty simple, though, and I’ll cover that in a minute.

What the script does is parse your Safari Reading List bookmarks directly from the PLIST file that Safari stores in your support folder. Safari doesn’t technically need to be open to do this, but it will only sync your latest bookmarks from other devices when it’s running. The app version of this script will launch Safari automatically, but you may want to add a command to any launchd setups directly using the script version to do so.

The date of each run of the script is recorded and only newer bookmarks are pulled the next time. If posting to Pinboard, bookmarks are marked with ‘toread’ as well as a ‘.readinglist’ tag (a private tag you can use for sorting and cleanup).

Setup

First, regardless of which version you run, you need to install the Python “pinboard” library, which can be done with:

easy_install pinboard

or pip install pinboard if you use pip. I don’t recall my setup having any trouble with permissions, but if you get an error, try using sudo easy_install pinboard (or sudo pip install...).

Configuration

Then there are just a couple of config settings that are currently hardcoded in the script/workflow. To edit the script, just open it in a text editor, to edit the workflow, right click and Open In… Automator.

Look for the block of text containing:

DEFAULT_EXPORT_TYPE = 'pb'
PINBOARD_API_KEY = 'XXXXXXX:XXXXXXXXXXXXXXXXXXXX'
BOOKMARKS_MARKDOWN_FILE = '~/Dropbox/Reading List Bookmarks.markdown'
BOOKMARKS_PLIST = '~/Library/Safari/Bookmarks.plist'
  • DEFAULT_EXPORT_TYPE can be set to “pb” (Pinboard), “md” (Markdown list), or “all” (exports both)
  • PINBOARD_API_KEY is your full Pinboard API Key.
  • BOOKMARKS_MARKDOWN_FILE can be any path (including filename) for an existing Markdown file
  • You shouldn’t need to modify BOOKMARKS_PLIST

That’s it.

Download

Here’s the script version, and you can grab the Automator Workflow below. Note that this is the first time I’ve ever published a Python script and I’m still feeling my way around building CLIs with it. I’m open to your thoughtful criticism.

ReadingListCatcher v1.0.0

A workflow and script for saving Safari Reading List bookmarks to Pinboard and/or Markdown

Updated Tue Jan 06 2015.

DonateMore info…