Reading List
Monday, July 15, 2013
The Safari browser has a feature called “Reading List” that makes it easy to synchronize and bookmark pages for later reading. Recently, a Mac OS Hint linked to a question on stackexchange.com asking how to get Reading List items as links.
The current answer is a Python script that:
- Finds the safari bookmarks plist file
- Copies the plist file to a temporary file
- Converts the plist file from binary to text format
- Parses it into a python object
- Finds the “Reading List” entry
- Prints out the saved URLs
I thought it would be fun to contrast that with a simple solution in Factor.
: reading-list ( -- urls )
"~/Library/Safari/Bookmarks.plist" read-plist
"Children" of [ "Title" of "com.apple.ReadingList" = ] find nip
"Children" of [ "URLString" of ] map ;
You can try it out in the listener to get something like this:
IN: scratchpad reading-list .
V{
"https://factorcode.org"
"https://news.ycombinator.com"
"https://reddit.com"
}