Delicious Tags in DTP

Hello,

first all I want to sing the gospel of DTP. It’s a great product. I have a one question, though. When I import my delicious bookmarks with the Applescript, the tags don’t seem to be imported. Is there any workaround for this?

Looking forward to your answers.

Thanks for the bug report! V2.0.2 will fix this glitch of the AppleScript suite.

Hello,

many thanks for addressing the problem. The tags are imported now. There’s still a minor glitch, however.

Delicious recognizes words separated by a “blank character” as two different tags, Devonthink doesn’t do this. This means that when I import a bookmark that has two tags attached to it, e.g. “devonthink” and “productivity”, Devonthink will create a tag named “devonthink productivity”. As a consequence, that the bookmark will not show alongside other bookmarks tagged with “producitivity”.

I know this is just a minor problem, but I have a couple of hundred of bookmarks stored in delicious and having to go through all of them to fix the tags seems like a lot of work.

V2.0.3 will include this script which should do this:


-- Import del.icio.us bookmarks
-- Created by Christian Grunenberg on Mon Jan 23 2006.
-- Copyright (c) 2006-2009. All rights reserved.

-- If the properties pUser and pPassword are undefined and the keychain doesn't contain a key for del.icio.us,
-- then a dialog pops up asking for these properties

property pUser : ""
property pPassword : ""

tell application id "com.devon-technologies.thinkpro2"
	try
		if (pUser is "") or (pPassword is "") then
			try
				tell application "Keychain Scripting"
					set theKey to first Internet key of current keychain whose name is "del.icio.us"
					set pUser to account of theKey
					set pPassword to password of theKey
				end tell
			end try
		end if
		
		repeat while (pUser is "") or (pPassword is "")
			set theResult to display authentication dialog "del.icio.us" & return & "https://api.del.icio.us/v1/posts/all"
			set pUser to user of theResult
			set pPassword to |password| of theResult
		end repeat
		
		set theXML to download markup from "https://api.del.icio.us/v1/posts/all" user pUser password pPassword encoding "UTF-8"
		
		if theXML is missing value or theXML is "" then
			error "Download failed."
		else if theXML contains "503 Service Temporarily Unavailable" then
			error "503 Service Temporarily Unavailable"
		else
			try
				tell application "System Events"
					set x to make new XML data with data theXML
					set theElements to XML elements of (XML element 1 of x) -- posts
					tell application id "com.devon-technologies.thinkpro2"
						set theGroup to get record at "/del.icio.us"
						if theGroup is missing value or type of theGroup is not group then
							set theGroup to create location "/del.icio.us"
							set thumbnail of theGroup to "http://l.yimg.com/hr/img/delicious.64px.gif"
						end if
					end tell
					repeat with theElement in theElements
						set theURL to (value of XML attribute named "href" of theElement) as string
						set theName to (value of XML attribute named "description" of theElement) as string
						set theTag to (value of XML attribute named "tag" of theElement) as string
						
						set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, " "}
						try
							set theTags to (text items of theTag)
						on error
							set theTags to {}
						end try
						set AppleScript's text item delimiters to od
						
						tell application id "com.devon-technologies.thinkpro2"
							if not (exists record with URL theURL) then create record with {name:theName, type:bookmark, URL:theURL, tags:theTags} in theGroup
						end tell
					end repeat
				end tell
			on error msg
				set pUser to ""
				set pPassword to ""
				error "Invalid user/password."
			end try
		end if
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

Many thanks. That solved the problem!