New Pinboard import and update script

Since the AppleScript explicitly checks and uses a variable theGroup, I am not sure how that could happen. But you never know :slight_smile:

Can you please double check that your group’s name is exactly “Pinboard”?

Also, do you know how to use the Script editor? If so, you could set a breakpoint in line 34 and inspect theGroup’s value.

This is a phenomenal script; thank you so much! I just wanted to mention that the gist has the debugging behavior of only pulling in recent posts, as opposed to all posts. It took me a few minutes to figure out why I was only seeing a handful of posts getting imported.

This has been working, except for when I try to import all posts, I constantly get the error in DevonThink:

“Pinboard Importer
503 Service Temporarily Unavailable”

This may be an issue on Pinboard’s side?

I have about 4000 bookmarks.

Jeff: Yeah, I have to clear this up. It’s down there in comment, but sure enough not obvious enough :wink:

bshapiro84: That’s an HTTP status code from Pocket saying something went wrong. What, why? No idea. The sheer number of posts shouldn’t be an issue, mostly because the update kicks on on the last one that got imported. I. e. even if you have to run the script a couple of times, it will import everything. Are you positive you entered the token correctly? What does the protocol say when the error appears?

This could also be a rate-limiting issue on Pinboard’s side.

My DT database was having some issues with my MacBook battery’s lack of voltage.

Lucky me, this gave me cause to reindex my Pinboard collection, and finding and fixing a bug in the script in the process.

Updated script: gist.github.com/itst/780dee5c51 … c39166eb0f (same link as in the first post.)

The bug: In line 39, in the if-clause, the code tested whether theGroupComment was an empty string. Well, it had to be, all the time, every time, because it was just initialized as such.
The bug will not give you headache under normal circumstances, but in case your DB goes haywire this might lead the script to try and get ALL your Pinboard posts. It will not import them, because they are duplicates. Still, it will take ages to run. You can remedy the situation by manually setting the group’s comment to a RFC 3339 compliant datetime string, such as 2018-12-01T13:14:49Z. Anyways, I rather fix a bug than use a workaround, so here you go.

Updated script: gist.github.com/itst/780dee5c51 … c39166eb0f (same link as in the first post.)

I set up a launchd script to run the import every day at 10pm. On completion, and on error, the script shows dialogs. Don’t want them when running on automatic, thus I introduced a flag that controls whether the dialogs appear or not. In turn, the flag is controlled by checking for a command line parameter.

Here’s my plist for launchd:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>net.itst.PinboardImport</string>

  <key>ProgramArguments</key>
  <array>
    <string>/usr/bin/osascript</string>
    <string>/Users/sascha/Library/Application Support/DEVONthink Pro 2/Scripts/Import/Pinboard.scpt</string>
    <string>silent</string>
  </array>

  <key>Nice</key>
  <integer>1</integer>

  <key>StartCalendarInterval</key>
  <dict>
    <key>Hour</key>
    <integer>22</integer>
    <key>Minute</key>
    <integer>4</integer>
  </dict>

  <key>RunAtLoad</key>
  <true/>

  <key>StandardErrorPath</key>
  <string>/tmp/Pinboard.err</string>

  <key>StandardOutPath</key>
  <string>/tmp/Pinboard.out</string>
</dict>
</plist>

See alvinalexander.com/mac-os-x/mac … unchd-jobs for more info on how to schedule a script via launchd.

See soma-zone.com/LaunchControl/ for an optional GUI tool to help setting that up.

1 Like

Updated script: https://gist.github.com/itst/780dee5c510db6d1327c34c39166eb0f … (same link as in the first post.)

After setting up the scheduled task I realized the script does not know which database to use. Wow. Ended up with all my +6k bookmarks in the global inbox :slight_smile:

Now it does know where to look for the group.

Itst,
Thanks for creating this.

Can you pls tell me step by steps how to set this up?

I don’t wanna keep asking or screw things up that’s why I wanna do it right.

Im good until pasting the script on the script editor but that’s it. Since this thread has so many updates I might miss a step.

Thanks

This is awesome. Except it makes me realise how many of the links I’d saved a decade ago are now dead. :open_mouth: And how many bookmarks I’d saved re: Aperture. :skull:

1 Like

Hello, I tried the script and it worked very well in importing existing Pinboard bookmarks, and the new bookmarks after the the last import. However, I don’t think this works entirely at least in my workflow. If I manage the existing bookmarks in Pinboard, such as manage tags, delete redundant bookmarks and so on in Pinboard, it won’t reflect to an already imported database in DEVONthink, which means I’d need to do similar operations in DEVONthink if I wanted to manage the bookmark library. Do you think if it’s doable to update changes in already imported items from Pinboard (changes in tags, description, deletions, etc), or what’s the best way to do it with the Pinboard API? I could spend some time to script it if there’s a sensible way to do it. I figure Pinboard clients such as Sillo (MacOS) and Pinner (iOS) get this changes through Pinboard API. I see there’s the /v1/posts/updateto check when data has changed last time.

Hi Hens! Wow, that took a while :frowning: If you still want help, let me know!

Hi juranta: That’s beside my use case, where I simply want to have my bookmarks in DT. I don‘t really »massage« my bookmarks in the way you describe.

(Looking at Pinboards API, I don’t see a way to query for „changed bookmarks since“. /v1/posts/recents seems to return newly added bookmarks.)

Hi itst! I kind of have an issue with having both personal, study and work related bookmarks, notes todos spread around multiple apps, to-read lists, inboxes, etc. Like forgetting where I put that data and having too many inboxes to process them all. So I’m trying to consolidate the system I have at hand.

Actually the last week I decided to move at my bookmarks from Pinboard to DEVONthink along with the notes, pdfs, etc I already have there. It’s with some rough edges, but it’s looking good so far. I actually thought I was using your script to download the bookmarks, but since I had installed DEVONthink 3, it was using some default Pinboard script instead. It didn’t import some important stuff such as the comments field. So, therefore I came back to this thread and used your great script, not to forget instructions, to download it all to DEVONthink. So thanks!

1 Like

Hi, Just seen this and I would use it loads to for Pinboard but I keep getting an error that says download failed. In the log I have
21:10:42: thePinboardURL: https://api.pinboard.in/v1/posts/all?auth_token=***********

Does this make sense to anyone? I’ve double checked my api token and it is correct, added the database and group called Pinboard.

Thanks in advance if your able to help

What happens if you copy & paste the URL from the log message into your browser‘s address bar and hit ENTER?

Can you provide a screenshot?

Best
Sascha

All I get when entering the address into the browser is a blank white browser. Here is a screenshot

You do have bookmarks in Pinboard already, right?

Yes I do, about 180 of them

OK. And the Token you copied into the script looks something like this:

<your Pinboard username>:<lots of numbers and characters>

If it does not, please have a look at https://pinboard.in/settings/password and copy the “API Token” that‘s displayed there into the script.

First off, thanks for your help. I double checked the details and everything was good. Just got home and decided to delete the script and start again and everything works :smile:
Have no idea if I accidentally deleted something from the script without noticing or something like that but it’s working now. Again thanks for your help, it’s awesome having Pinboard in Devonthink