Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - Add tags and modify comments of annotations #154

Closed
Mjvolk3 opened this issue May 1, 2022 · 8 comments
Closed

Feature Request - Add tags and modify comments of annotations #154

Mjvolk3 opened this issue May 1, 2022 · 8 comments
Assignees

Comments

@Mjvolk3
Copy link

Mjvolk3 commented May 1, 2022

Currently the Zotero.add_tags() only works for metadata tags, but it would be convenient to modify tags and even update comments of annotations. It wouldn't make much sense to modify the other items of the annotation dict, maybe annotation color. My use case is to connect Zotero notes to Dendron a note taking tool in VsCode. After importing notes to Dendron, I would like to be able to modify them there, and write the changes back to Zotero. This would be possible with the requested feature. Thanks for your consideration.

@urschrei
Copy link
Owner

urschrei commented May 1, 2022

This isn't currently supported by the Zotero API. See #148

@Mjvolk3
Copy link
Author

Mjvolk3 commented May 1, 2022

Thanks for your speedy response! From what I saw it looks like the issue is that they haven't documented it yet.

@urschrei
Copy link
Owner

urschrei commented May 1, 2022

Hmm. I'll have to think about what the API looks like, and I'm hesitant to add public API methods for undocumented features.

In the mean time, v1.5.3 (just released to pypi) now supports annotation fields, so you can modify annotation items (retrieved as per #148), by altering their ['data']['annotationComment'] and ['data']['tags'] keys, then write the changes to your library using update_item(modified_item). I just tried this and the changes appear exactly as you would expect.

@Mjvolk3
Copy link
Author

Mjvolk3 commented May 2, 2022

Ok I have upgraded to v1.5.3.

all_annotations = zot.everything(zot.items(itemType="annotation"))
print(all_annotations[0])
zot.add_tags(all_annotations[0], "test-tag")
# Error
> InvalidItemFields: Invalid keys present in item 1: annotationText

Strangely the tag is added before the template check.

print(all_annotations[0]['data']['tags'])
> [{'tag': 'test-tag'}]

Since it is updated I try the following, and of course get the same error.

zot.update_item(all_annotations[0])
# Error
> InvalidItemFields: Invalid keys present in item 1: annotationText

I check the template on zotero.py and the annotationText is not a supported field. The following annotations fields are supported.

# annotation fields
"annotationColor",
"annotationType",
"annotationPageLabel",
"annotationPosition",
"annotationSortIndex",
"annotationComment",

Seems strange that "annotationText" isn't here. How were you able to get things to work?

@urschrei
Copy link
Owner

urschrei commented May 2, 2022

🤦‍♂️ I left out annotationText. I've just pushed 1.5.4 to pypi – try that? (sorry!)

@Mjvolk3
Copy link
Author

Mjvolk3 commented May 2, 2022

Works perfectly now. Thank you!

@EricThrift
Copy link

annotationAuthorName is also missing from the list of known keys in zotero.py, around line 1140. This prevents pyzotero from updating PDF annotations when sending back a modified version of the json returned by the API.

@urschrei
Copy link
Owner

urschrei commented Jul 5, 2022

@EricThrift Oops. Just published 1.5.5 with a fix.

urschrei added a commit that referenced this issue Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants