Script: Import Kindle notes to DEVONthink

I have posted a first draft of a script which imports Kindle notes (highlighted passages and associated user notes) into the selected DEVONthink group.

The script creates RTF notes in the same format as my Sente, Skim, and Mekentosj Papers2 scripts. (A separate DEVONthink group is used/created for each book).

If you have created a custom Devnote.css file for any of these scripts in your scripts folder, it will be used by this script too, and apply the styles which it contains.

As with the other scripts, this aims to facilitate the kind of work-flow described by Steven Berlin Johnson in various articles.

Note that by default the script imports notes from the kindle.amazon.com/your_highlights web pages (which have the richest set of data fields, and allow for the creation of some useful hyperlinks in the DT records - jumping, for example, to the relevant passage in the OS X Kindle app).
The script will, however, also offer to import notes from the My Clipping.txt file on a Kindle device, or from any text file which uses the same format.

(The technically curious will find the current draft of the parsing logic in perl files inside the script bundle.

The HTML parsing uses the HTML::TokeParser library, and the TXT parsing uses Date::Parse
and Date::Language

As far as I can see these libraries seem to be part of the standard OS X 10.6 perl installation …)

Updated with some improvements (and fixes), especially for the My Clippings.txt importer.

I must be missing something basic.

I’m trying to process a “My Clippings.txt” file with Kindle2Devon017.scptd, and it’s throwing errors.

First, after selecting the file and the book, and bypassing the ASIN, I get the following:

This occurs whether I run the script from the AppleScript editor or save it as an application and run it from there.

OK, so I work around that by changing


property pstrTmpKlips : POSIX path of (path to me) & "mytmpKlips.txt"

to use (path to desktop) instead. Then I get:

I could hack around this, of course, but it appears that I’m missing something obvious here. What am I doing wrong?

Thanks for this feedback.

Are you using OS X 10.6 ?

It might be helpful to see the full paths involved in the command lines which are throwing errors.

Could you email them to houthakker72, which is a gmail.com address ?

(Ver 0.19 bypasses the second error and defaults to English (for date parsing) if the .GlobalPreferences AppleCollationOrder setting can’t be read. It also places temporary files on the desktop, rather than inside the script bundle.)

(Ver 0.25 allows for clippings files which are delimited by 0d0a, and no longer chokes on unusual text patterns in title/author lines. It also filters out bookmarks, and, in the Kindle notes web-page parser, bypasses what appears to be a new source-saving bug in Safari.)

This looks wonderfully helpful. I successfully imported the annotations/notes from a first book. But when I ran the script on the highlights page for a second book, I ended up with a new group that contains the annotations from both the second and the first book. Am I doing something wrong.

Cheers,

Mark

Notes are exported to whichever group is currently selected in DevonThink - might the the first book’s group in DT have been selected when the second group’s notes were exported ?

I think I found the issue. When running the script on the highlights from Book 1, the script writes to a temporary file, “mytmpKN2html.html,” on the Desktop. When running the script for annotations from Book 2, it is writing to the same temp file, adding to those from Book 1, and importing all into DTP. If I manually delete “mytmpKN2html.html” between uses of the script, it behaves as expected.

Cheers,

Mark

Thank you – I’ll take a look at that.

Are you using Lion ?

(On 10.6 here further runs overwrite the tmp file rather than appending to it).

Yes, I’m using Lion.

Looks like Amazon have now removed the book-specific ‘your highlights’ pages, breaking this script.

I would need to rewrite the Perl script in the resources folder of the .scptd bundle to mend it. Probably won’t get to that for at least a couple of weeks.

In the meanwhile, for anyone who enjoys a bit of Perl hacking, the source code is there :slight_smile:

Would this script still function on the clippings text file? If so, could I implore you to post a new link? All of the MobileMe links are dead.

Thanks!

I think it should, in principle.

I hope to get to this in a couple of weeks - a little too busy at the moment.

http://www.complexpoint.net

That’s fantastic! Thanks so much.

Just chiming in to say that I hope you (or someone else) will be able to find time to update this, houthakker. It looks really useful and I can’t find anything else to do the same job (there is another script at digitalnotions.net/importing-kin … think-pro/ but I can’t get it to work for me).

I understand that a fork of this (updated to cope with the new structure of Amazon’s notes pages) is in preparation - the broken version is on Github, and we’re planning to pull the updates into it when its ready.

Good news, thanks.

As mentioned by houthakker I’ve taken some time to look at this script since it was broken by Amazon’s new page layout. Finishing my ebooks and not being able to import my highlights into DEVONthink was such a pain that I tried to overcome my noob scripting abilities and finally made it work.

Please feel free to download the new version of the script and test it. The instructions are basically the same for the original script, except for the page you are going to navigate to in order to use it.

The highlight page for a specific book is now accessed from a link in the ebook popular highlights page:

  1. Starting from kindle.amazon.com/your_highlights, click on a book title. This will take you to the book page that includes shared notes and popular highlights.

  2. In the upper right corner of this page there is a link to your personal highlights saying “You have n highlighted passages”. Click on this link.

  3. This will lead you to a page with the following URL structure: kindle.amazon.com/your_highlight … /BOOK_ASIN. That’s the page where the script actually works now.

You can download the new script here:
github.com/RobTrew/tree-tools/b … 27beta.zip

KNOWN BUGS:

  1. Temporary HTML file is not deleted from Desktop
  2. Ebook title is not detected when writing DevonThink files and folders

Cheers,
Marco Pessoa

Works for me. Very useful - thanks a lot.

Thanks. It seems to work for me too.

Thanks Marco !

( I’ve updated the links here and on www.complexpoint.net )