There are quite a few things I love when it comes to my Mac. I love Spotlight. I love OpenMeta tagging. I love Evernote. I love being able to collect information from any source, and find anything I’ve saved, anywhere, no matter what program I used to create it. I especially love programs that allow me to accomplish that.
Unfortunately, one of my favorite apps right now, Delibar, doesn’t integrate with Spotlight or OpenMeta, despite the fact that it would be relatively easy to do. Delibar is an excellent (and sexy) menubar application for creating and searching Delicious (and Pinboard) bookmarks. A similar app, Pukka, pulls off the Spotlight part, but I still wanted OpenMeta tags that matched my Delicious tags for local searching.
I also use Tags.app for most of my tagging. OpenMeta tags allow you to group and classify files with simple tags, and provide a Spotlight-compatible way to search more intelligently. When you tag a website with Tags, it creates a webloc file in your metadata cache and applies the OpenMeta tags to it. I figured a similar approach would be feasible using AppleScript, and it seems to be working out great. Read on to see the script I’m using, and be sure to let me know if you improve on it!
What I’m doing is using curl with the Delicious API, and downloading everything that’s been bookmarked within the last hour. I’m running it with launchd every hour, so I don’t want to grab more than that every time it runs. It parses out the title, tags and url for the bookmark, saves it to a .webloc file, and tags it using Tags.app’s AppleScript commands. If you’re not running Tags, it could be modified pretty easily to work with the
openmeta command line application.
I’m leaving the target folder up to the user, so when you define it in the CONFIG section, make sure it’s pointing to an existing folder. The only other config properties are your Delicious username and password (sent securely). As noted in the comments in the script, you can adjust the time/date it retrieves from in the first line after the CONFIG section.
The script is pretty well commented, so I won’t rewrite the whole thing here. Take a look, and then I’ll show you how I installed it.
The first thing I did was make a version of the script that excluded the date parameter (fromdt) in the curl call in order to download my entire history and process it so I was up-to-date. This took a while, but didn’t seem to cause any problems. The Delicious API is pretty quick to throttle you, so download the whole bunch in one API call or you’ll be in trouble.
After editing the config options, I saved the file as an
Application Bundle in my own apps directory (~/Applications). It doesn’t matter where you put it (or what you name it), as long as you know the path to get there. Then I set up a launchd plist to run it every 3600 seconds (hour). I highly recommend Lingon for editing all things launchd. It will make sense when you get there.
In reference to the install procedure above, I’ve actually had more luck saving it as a text file to a scripts folder and running it with osascript through launchd. Here’s my launchd plist, which you can edit and load through the “Expert” section of Lingon’s editor.
Also, as I just added into the code comments above, I didn’t originally account for the fact that Delicious dates are in GMT, and my offset is -5 right now, so I have to use -v+4H to get 1 hour back, not -v-1H.
Areas for improvement:
- Currently errors out on some bookmarks for unknown reasons
- Could have a first-run setting to automatically download and tag ALL bookmarks
- Could set the created date of the webloc file based on the date of the bookmark from Delicious
- Could provide more feedback or logging