as a huge fan of Instapaper using it on a daily basis and also using DT to view my RSS feeds, I prepared a piece of AppleScript to add selected feed entries
to my Instapaper account.
Before using it, please set the right account’s name in the script’s content.
Here we go:
set username to "username"
-- remove this part to turn off Growl notification
tell application "GrowlHelperApp"
set the allNotificationsList to {"Success Notification"}
set the enabledNotificationsList to {"Success Notification"}
register as application ¬
"Add to Instapaper" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "DevonTHINK Pro"
end tell
tell application "DEVONthink Pro"
set selectedItems to selection
show progress indicator "Adding articles to Instapaper..." steps (count of selectedItems)
repeat with selectedItem in selectedItems
set itemURL to URL of selectedItem
if itemURL is not "" then
set itemName to name of selectedItem
step progress indicator
set command to "/opt/local/bin/curl --data-urlencode \"username=" & username & "\" --data-urlencode \"url=" & itemURL & "\" --data-urlencode \"auto-title=1\" http://www.instapaper.com/api/add"
do shell script command
-- remove this code to turn off Growl notification
tell application "GrowlHelperApp"
notify with name "Success Notification" title "Added to Instapaper!" description itemName application name "Add to Instapaper"
end tell
end if
end repeat
hide progress indicator
end tell
please try to replace “opt/local/bin/curl” with “curl” - but it doesn’t work on my Mac this way so I can’t promise anything. If still having problems, please let me know.
I’m sorry I don’t understand any of this. And none of it works.
Thanks for the help, but this is another of those impenetrable mysteries of computers – why a script that works fine on one Mac should not work on another.
Hey, if you really want to get into some esoteric programming, I have a pretty decent (and still working) HP-67 calculator that I’m going to put up on ebay soon!
[Hint to Eric: Too bad Devon Tech doesn’t have a "trading post’ forum for us users.]
Actually a descendant of the hp67’s programming model is still alive in the hp-50 (or something like that, I have an hp-49g which I bought some years ago to play with and apparently it’s similar). these things are basically like supercharged hp-48g calculators; quite amazing for when they were introduced, and programmable in RPL, which is a language evolved from hp67-style programming. I don’t have much time to play with it anymore, unfortunatey.
having added a bit of extra software provided by enthusiasts (including an editor called “emacs”…), the source code (or an on-the-fly disassembled version of it) for the whole operating system is available at a keystroke. completely amazing. a battery-powered lisp machine!
unfortunately, RPL programs are completely unreadable 1 day after you write them, at least for me. at any rate, at the moment I have a program called “spacetime” on my ipod touch, which is nice for a little mathematical programming, but I guess in a few years I’ll just have mathematica on my then-current mobile phone. should be incredibly cool and enough for everything. [although come to think of it, if someone had told me, while I was fighting with my 8mhz, 640kb, no hard-disk, CGA graphics beast of a machine as a geeky pre-teenager, that I’d be able to open my macbook on a plane and continue programming in mathematica for hours, never mind the GUI and so on, I’d probably have thought that nothing could possibly top that-now I am instead irritated that my battery runs out]
As promised, here comes a version of this script using python interpreter internally. It should work if the version above didn’t work on your mac. This one should do.
Please adjust the parameters at the beginning of the script. Also notice the very long line ‘set command to python …’ - it has no line breaks, please don’t break it.
set username to "your username"
set pwd to "password"
-- remove this part to turn off Growl notification
tell application "GrowlHelperApp"
set the allNotificationsList to {"Success Notification"}
set the enabledNotificationsList to {"Success Notification"}
register as application ¬
"Add to Instapaper" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "DevonTHINK Pro"
end tell
tell application "DEVONthink Pro"
set selectedItems to selection
show progress indicator "Adding articles to Instapaper..." steps (count of selectedItems)
repeat with selectedItem in selectedItems
set itemURL to URL of selectedItem
if itemURL is not "" then
set itemName to name of selectedItem
step progress indicator
set command to "python -c \"instapaper_username='" & username & "'; instapaper_password='" & pwd & "'; import httplib, urllib; params = urllib.urlencode( {'username': instapaper_username, 'password': instapaper_password, 'url': '" & itemURL & "', 'auto-title': '1' } ); headers = {'Content-type': 'application/x-www-form-urlencoded','Accept': 'text/plain'}; conn = httplib.HTTPConnection('www.instapaper.com'); conn.request('POST', '/api/add', params, headers); response = conn.getresponse(); print response.status, response.reason\""
do shell script command
-- remove this code to turn off Growl notification
tell application "GrowlHelperApp"
notify with name "Success Notification" title "Added to Instapaper!" description itemName application name "Add to Instapaper"
end tell
end if
end repeat
hide progress indicator
end tell
Whoops - spoke too soon. It looks like it’s working, makes all the right noises, reports that it’s done it – but when I go to instapaper.com, there’s no sign of the articles I supposedly saved to it. Hmmm…
Choose whichever version, above, you want. Press “Select All” then copy (command-c).
Open AppleScript Editor app in /Applications/Utilities.
Create a new document, paste the clipboard and click “Compile” on the toolbar.
From AppleScript Editor save to ~/Library/Application Support/DEVONthink Pro 2/Scripts/My Scripts – the “MyScripts” folder is a folder you would create – call it whatever you want – where you put your own scripts so as to avoid having them overwritten if you update DEVONthink in the future. (Small risk, but good to avoid.)
After saving, then the script will appear within the Scripts menubar item in DEVONthink