#ACL All:read = NetNewsWire + Pocket = This is an [[http://developer.apple.com/applescript/|AppleScript]] to post articles to [[http://getpocket.com|Pocket]] (a.k.a. Read It Later) from the [[http://netnewswireapp.com/|NetNewsWire]] RSS feed reader on Mac OS X. = Installation = [[http://jaidev.info/hacks/NetNewsWire+Pocket.scpt|Download the script]] and copy it to the location: {{{/Users//Library/Application Support/NetNewsWire/Scripts/}}} You should now see a new menu item under the scripts menu called '!NetNewsWire+Pocket' that posts the current article to Pocket. Clicking on that will prompt you to provide access to your getpocket.com credentials if you've already saved them to the [[http://en.wikipedia.org/wiki/Keychain_Access|keyring]]. If not, it'll ask you for your login details and save them to the keyring. Once that's done, you're all systems go for super fast feed reading! == Configuring a Keyboard Shortcut == You can configure a keyboard shortcut for this action by going to System Preferences > Keyboard > Keyboard Shortcuts > Application Shortcuts and adding a application shortcut with these parameters: * Application: '''!NetNewsWire''' * Menu Title: '''!NetNewsWire+Pocket''' * Keyboard Shortcut: Any key combination. (I use '''⌘ D'''). = Source Code = {{{ -- NetNewsWire+Pocket: Add items to Pocket (Read It Later) from NetNewsWire. -- Copyright (c) 2005-2011, Jaidev K Sridhar -- Released under the GPL license version 2. http://www.gnu.org/licenses/gpl-2.0.html -- Version: v20120613-1 -- INSTALLING: -- Copy NetNewsWire+Pocket.scpt to /Users/$USER/Library/Application\ Support/NetNewsWire/Scripts/. A new item 'NetNewsWire+Pocket' shows up in the scripts menu when NetNewsWire is restarted. -- ADDING A KEYBOARD SHORTCUT: -- To configure a keyboard shortcut, open System Preferences > Keyboard > Keyboard Shortcuts > Application Shortcuts. Add a keyboard shortcut with these parameters: -- * Application: NetNewsWire -- * Menu Title: NetNewsWire+Pocket -- * Keyboard Shortcut: Any key combination. (I use CMD + D). tell application "GrowlHelperApp" set the allNotificationsList to {"Success Notification", "Error Notification"} set the enabledNotificationsList to {"Success Notification", "Error Notification"} register as application "NetNewsWire+Pocket" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "NetNewsWire" end tell tell application "NetNewsWire" if index of selected tab = 0 then -- We're looking at headlines, so just get the headline URL set feed_url to URL of selectedHeadline set feed_title to title of selectedHeadline else -- We're looking at a web view tab, so we need to know which tab set i to index of selected tab set i to i + 1 -- Get the tab's URL set URL_list to URLs of tabs set title_list to titles of tabs set feed_url to item i of URL_list set feed_title to item i of title_list end if set pocket_user to do shell script "security 2> /dev/null find-internet-password -gs getpocket.com | grep acct | cut -d '\"' -f4" if pocket_user = "" then display dialog "Pocket (Read it Later) username: " with title "NetNewsWire+Pocket" default answer "" buttons {"OK"} default button 1 set pocket_user to (text returned of result) display dialog "Enter password for " & pocket_user & " on Pocket: " with title "NetNewsWire+Pocket" default answer "" buttons {"OK"} default button 1 with hidden answer set pocket_pass to (text returned of result) set qpass to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of pocket_pass set auth_url to "https://readitlaterlist.com/v2/auth?username=" & pocket_user & "&password=" & qpass & "&apikey=e7dd1Ne1TfY49E1d78A573ete5g5k2c2" set cmd to "curl '" & auth_url & "'" set ret to do shell script (cmd) if "200 OK" is in ret then set cmd to "security add-internet-password -D 'Web form password' -r 'http' -a " & pocket_user & " -s getpocket.com -w " & pocket_pass & " -l 'getpocket.com (" & pocket_user & ")' -j default" do shell script cmd else display dialog "Failed to authenticate user '" & pocket_user & "' on getpocket.com (" & ret & "). Please retry." with title "NetNewsWire+Pocket" buttons {"OK"} return end if else set pocket_pass to do shell script "security find-internet-password -s getpocket.com -g 2>&1 >/dev/null | cut -d '\"' -f2" end if set qurl to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of feed_url set qtitle to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of feed_title set qpass to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of pocket_pass set pocket_url to "https://readitlaterlist.com/v2/add?username=" & pocket_user & "&password=" & qpass & "&apikey=e7dd1Ne1TfY49E1d78A573ete5g5k2c2&url=" & qurl & "&title=" & qtitle set cmd to "curl '" & pocket_url & "'" set ret to do shell script (cmd) if "200 OK" is in ret then tell application "GrowlHelperApp" notify with name "Success Notification" title " Added to Pocket" description feed_title & " (" & feed_url & ")" application name "NetNewsWire+Pocket" end tell else tell application "GrowlHelperApp" notify with name "Error Notification" title "Can't Add to Pocket" description feed_title & " (" & feed_url & ")" application name "NetNewsWire+Pocket" end tell end if end tell }}}