Applescript to import articles into devonthink pro and del.icio.us from incoming NetNewsWire RSS streams

August 1st, 2007

The applescript in this post will take the currently selected headline or tabbed article in NetNewsWire, prompt the user for tags about the article, and then create an HTML copy of the article in DEVONThink in a sub group.

If the first tag is not the word “private” then the link is also posted, via cocoalicious, to my del.icio.us account.

This was based on my prior script and Ethan’s attempt to deal with info overload.

It attaches the referral URL to the DEVONThink record, so when it creates the archive, it will actually fetch the article from the original source (ex. del.icio.us posts get the original article)

Since DEVONThink doesn’t really do tags, I’ve co-opted the “comments” field for this purpose.

This is attached to a Quicksilver trigger (CMD-CTR-OPTION-/).

Here is the workflow:

  • SCAN: Quickly scan headlines in NetNewsWire and hit return when I see a headline that seems interesting. This opens the page in the background in a tab in NNW
  • READ: Go down list of articles, skim them, do CMD-CTR-OPTION-/ for those I’d like to possibly include in future research to invoke my script. * In the prompt that appears, type a few keywords/tags that describe the content and hit “return”
  • REVIEW: Later on, when doing research or work around a topic, I can use DEVONThink’s smart searching features confidently knowing that it will dig up at least some interesting connections between articles I saved.

Things to do:

  • add a growl notification saying “successful import”
  • write a looping script that will handle the few hundred articles marked as “flagged” in NNW by archiving them. What would the tags be here?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
set destination_group_location to "/url/delicious/"
 
tell application "NetNewsWire"
	set userInput to text returned of (display dialog "Enter Tag:" default answer "untagged")
 
	set h_tags to userInput
 
	set AppleScript's text item delimiters to space
	set h_tags to h_tags's text items
	set AppleScript's text item delimiters to {""}--> restore delimiters'
 
	try
		if (index of selected tab is not 0) then
			set tabnum to index of selected tab + 1
			set taburls to URLs of tabs
			set h_URL to (get item tabnum of taburls)
			set tabtitles to titles of tabs
			set h_title to (get item tabnum of tabtitles)
			set h_mdate to get current date
			set h_when to current date
 
		else if exists selectedHeadline then
			set h_URL to URL of selectedHeadline
			set h_title to title of selectedHeadline
			set h_mdate to get current date
			if exists date published of selectedHeadline then
				set h_when to date published of selectedHeadline
			else
				set h_when to date arrived of this_headline
			end if
		else
			error "No headline is selected."
		end if
	on error error_message number error_number
		if the error_number is not -128 then
			try
				display alert "NetNewsWire" message error_message as warning
			on error number error_number
				if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
			end try
		end if
	end try
 
	tell application "DEVONthink Pro"
		if item 1 of h_tags is "private" then
			set destination_group_location to destination_group_location & item 2 of h_tags
		else
			set destination_group_location to destination_group_location & item 1 of h_tags
		end if
 
		if not (exists record at destination_group_location) then
			set destination_group to create location destination_group_location
		else
			set destination_group to get record at destination_group_location in current database
		end if
 
		set archive to create record with {name:h_title, type:html, creation date:h_when, modification date:h_mdate, URL:h_URL, comment:userInput} in destination_group
		set source of archive to download markup from h_URL
 
	end tell
 
	tell application "Cocoalicious"
		if item 1 of h_tags is not "private" then
			make new post with properties {description:h_title, url:h_URL, tag string:userInput}
		end if
	end tell
 
end tell

Technorati Tags: , ,

2 Responses to “Applescript to import articles into devonthink pro and del.icio.us from incoming NetNewsWire RSS streams”

  1. Adam Rice Says:

    To get Growl working, add this at the top level of your script tell application “GrowlHelperApp” set the allNotificationsList to ¬ {”devonthink importer notification”, “Another Test Notification”} set the enabledNotificationsList to ¬ {”devonthink importer notification”} — change “devonthinkimporter” to whatever you actually name the script file. register as application ¬ “devonthinkimporter” all notifications allNotificationsList ¬ default notifications enabledNotificationsList ¬ icon of application “Mail” end tell

    Then add the following wherever you want to execute your “if success” condition:

    tell application “GrowlHelperApp” set the allNotificationsList to ¬ {”devonthink importer notification”, “Another Test Notification”}

    set the enabledNotificationsList to ¬
        {"devonthink importer notification"}
    
    
    --  rename devonthinkimporter to script file name
    notify with name ¬
        "devonthink importer notification" title ¬
        "devonthink importer" description ¬
        "Import succeeded" "devonthinkimporter"
    
    notify with name ¬
        "Another Test Notification" title ¬
        "Another Test Notification :) " description ¬
        "Alas — you won't see me until you enable me..." application name "devonthinkimporter"
    

    I think that’ll work

  2. Adam Rice Says:

    err, formatting came through a little borked.

Leave a Reply

Other Recent Articles

Browse Archives

Or Search