sdx23 / zotadd

A simple script to add pdf-files to Zotero via CLI
MIT License
12 stars 0 forks source link

Specify a library/collection to add the file #1

Open olivierguillard opened 3 years ago

olivierguillard commented 3 years ago

Very useful tool to provision my zotero repository.

But I would also like to specify the library/collection into which the document would be stored.

I have tried to include in the json part of "zotadd" a parameter "collection", but it doesn't work.

Any help ?

sdx23 commented 3 years ago

The API doesn't seem to have a nice documentation, but the implementation can be found here: https://github.com/zotero/zotero/blob/master/chrome/content/zotero/xpcom/connector/server_connector.js

The way to go is apparently using a sessionID for the "saveSnapshot" request and then doing "updateSession" to set tags/target. However, you have to specify the target collection by its id. You can retrieve a list of collections by "getSelectedCollection" and retrieve the id corresponding to the name of the desired target collection.

I'd be happy to receive a PR on this :)