So sorry for the delayed reply here, I stopped getting notifications for a little bit there. I think I responded to this on the DT forum, but will repeat here.
I believe the issue is that I developed the script while using the v4 beta and didn’t realize that the update command wasn’t available on records in DT3. I removed that bit of code from the script, so if you grab the latest version, it should work. Please let me know if it doesn’t.
I found a major flaw with the script. I had commented out the offending lines, but when the highlight was injected it overflowed the comment lines and caused an AppleScript error every time. Fixed now.
Unfortunately, it’s still not working for me, on either of my two Macs (a MBP M1 Pro and an M2 Studio Max, both with MacOS 15.3.1 and DT3 3.9.8). The token is definitely right.
This is what I get:
$ readwise_to_devonthink.rb -d [13:50:20]
INFO: Last update record does not exist
INFO: 20 new highlights
INFO: Saved last update: 2025-02-28T13:50:30.662+0000
95:170: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
93:168: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
ERROR: Error getting annotation for Save Readwise Highlights to DEVONthink GitHub
ERROR: Error undefined method 'empty?' for nil
Sorry, but this is way out of my comfort zone so I can’t offer any suggestions. I’m happy to try out anything you would like testing though.
Still getting an error, but it seems to be getting further: it’s now breaking on each import, rather than as a whole. I’ve omitted the repeating lines in the middle, but includex the final curl errors and no implicit conversion etc, at the end of the output.
Thanks again!
$ readwise_to_devonthink.rb -d [15:31:42]
INFO: Last update record does not exist
INFO: 20 new highlights
INFO: Saved last update: 2025-02-28T15:31:48.313+0000
95:170: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
93:168: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
ERROR: Error getting annotation for Save Readwise Highlights to DEVONthink GitHub
161:236: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
⁉️ Error saving Save Readwise Highlights to DEVONthink GitHub
ERROR: Error saving bookmark Save Readwise Highlights to DEVONthink GitHub
95:148: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
93:146: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
ERROR: Error getting annotation for Emacs for Writing Prose
161:214: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
⁉️ Error saving Emacs for Writing Prose
ERROR: Error saving bookmark Emacs for Writing Prose
95:185: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
93:183: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
ERROR: Error getting annotation for Preventing a Mac Laptop From Turning on When Opening Its Lid
161:251: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
(LINES OMITTED)
⁉️ Error saving Apple Intelligence Is Coming. Here's What It Means for Your iPhone
ERROR: Error saving bookmark Apple Intelligence Is Coming. Here's What It Means for Your iPhone
95:161: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
93:159: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
ERROR: Error getting annotation for Why Are We Still Eating So Much Meat?
161:227: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
⁉️ Error saving Why Are We Still Eating So Much Meat?
ERROR: Error saving bookmark Why Are We Still Eating So Much Meat?
95:140: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
curl: option : blank argument where content is expected
curl: try 'curl --help' or 'curl --manual' for more information
ERROR: Error no implicit conversion of nil into String
Looks like I’m going to have to dig my copy of DT3 back up to debug. I’m not getting any of these errors with 4. That last error on the curl call would be because something didn’t return a URL for a bookmark, which I thought I had fully handled, but apparently not.
Will look back into this over the weekend. It really is a useful script when it works…
I just installed DT3 and ran a test with 10 highlights and it worked perfectly.
Could you run the script with readwise_to_devonthink.rb -v and put the full output into a gist I could review?
(side note, I updated the gist with a slightly modified version that now captures quotes and html tags around highlighted Markdown sections better. Shouldn’t have any effect on the issues you’re seeing, though.)
Sorry, don’t know how to create a gist, so I’ve attached a text file: hope that’s ok. I created a new highlight, so the log is only picking one up, to make things simpler.
Ok, I think I got it. You clearly had your database/group set to “global” and “inbox” and I hadn’t fully tested with that configuration. It should now work like that, or you can specify a database and group and circumvent the issue entirely.
Grab the latest version of the script and it should function with your current settings.
This is the result with the standard script – i.e. with your default ‘global’ and ‘inbox’ settings.
$ readwise_to_devonthink.rb-copy -v [14:57:09]
INFO: 1 new highlights
INFO: Saved last update: 2025-03-01T14:57:24.684+0000
95:129: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
93:127: execution error: DEVONthink 3 got an error: Invalid argument in (-50)
ERROR: Error getting annotation for Date
tell application id "DNtp"
set theGroup to inbox
set searchResults to search "name:\"Date\"" in theGroup
if searchResults is not {} then
set theRecord to item 1 of searchResults
return plain text of (annotation of theRecord)
end if
end tell
ERROR: Error undefined method 'empty?' for nil
["/Users/david/bin/readwise_to_devonthink.rb-copy:735:in 'Import#save_to_dt'", "/Users/david/bin/readwise_to_devonthink.rb-copy:509:in 'block in Import#save_all'", "/Users/david/bin/readwise_to_devonthink.rb-copy:508:in 'Array#map'", "/Users/david/bin/readwise_to_devonthink.rb-copy:508:in 'Import#save_all'", "/Users/david/bin/readwise_to_devonthink.rb-copy:993:in '<main>'"]
If I change the name of the database/group to one of my other databases (‘Notes’ and ‘Inbox’), I get a longer response: