dhondta / zotero-cli Goto Github PK
View Code? Open in Web Editor NEWTinyscript tool for sorting and exporting Zotero references based on pyzotero
License: GNU General Public License v3.0
Tinyscript tool for sorting and exporting Zotero references based on pyzotero
License: GNU General Public License v3.0
Running into an issue downloading the attachments. Seems like annotations aren't supported yet.
zotero-cli --verbose
23:36:16 [DEBUG] Getting collections from cache '/home/user/.zotero/cache/collections.json'...
23:36:16 [DEBUG] Getting items from cache '/home/user/.zotero/cache/items.json'...
23:36:16 [DEBUG] Getting attachments from zotero.org...
^TTraceback (most recent call last):
File "/home/user/.pyenv/versions/3.10.6/bin/zotero-cli", line 117, in __init__
with cached_file.open() as f:
File "/home/user/.pyenv/versions/3.10.6/lib/python3.10/site-packages/pathlib2/__init__.py", line 1548, in open
return io.open(
File "/home/user/.pyenv/versions/3.10.6/lib/python3.10/site-packages/pathlib2/__init__.py", line 1383, in _opener
return self._accessor.open(self, flags, mode)
File "/home/user/.pyenv/versions/3.10.6/lib/python3.10/site-packages/pathlib2/__init__.py", line 646, in wrapped
return strfunc(str(pathobj), *args)
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.zotero/cache/attachments.json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.10.6/bin/zotero-cli", line 889, in <module>
z = ZoteroCLI(args.id, ["user", "group"][args.group or GROUP_FILE.exists()], args.key)
File "/home/user/.pyenv/versions/3.10.6/bin/zotero-cli", line 145, in __init__
raise ValueError("Unknown item type '%s'" % c['data']['itemType'])
ValueError: Unknown item type 'annotation'
I think this tool looks really good! It would be great to have more export options (say to MD, HTML, text) and flexibility in what data you can export. However I do not know if that is outside of the focus of this.
% ls $HOME/.zotero/cache
collections.json items.json
% zotero-cli -v
18:13:31 [DEBUG] Getting collections from zotero.org...
18:13:31 [DEBUG] Saving collections to cache '/home/user/.zotero/cache/collections.json'...
18:13:31 [DEBUG] Getting items from zotero.org...
18:14:17 [DEBUG] Saving items to cache '/home/user/.zotero/cache/items.json'...
18:14:18 [DEBUG] Getting attachments from zotero.org...
Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.10.6/bin/zotero-cli", line 114, in __init__
with cached_file.open() as f:
File "/home/user/.pyenv/versions/3.10.6/lib/python3.10/site-packages/pathlib2/__init__.py", line 1548, in open
return io.open(
File "/home/user/.pyenv/versions/3.10.6/lib/python3.10/site-packages/pathlib2/__init__.py", line 1383, in _opener
return self._accessor.open(self, flags, mode)
File "/home/user/.pyenv/versions/3.10.6/lib/python3.10/site-packages/pathlib2/__init__.py", line 646, in wrapped
return strfunc(str(pathobj), *args)
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.zotero/cache/attachments.json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.10.6/bin/zotero-cli", line 888, in <module>
z = ZoteroCLI(args.id, ["user", "group"][args.group or GROUP_FILE.exists()], args.key)
File "/home/user/.pyenv/versions/3.10.6/bin/zotero-cli", line 135, in __init__
if i['meta']['numChildren'] > 0:
KeyError: 'numChildren'
Creating the file as empty json works
% echo "{}" > $HOME/.zotero/cache/attachments.json
% echo "{}" > $HOME/.zotero/cache/notes.json
% echo "{}" > $HOME/.zotero/cache/annotations.json
zotero-cli -v
18:28:37 [DEBUG] Getting collections from cache '/home/user/.zotero/cache/collections.json'...
18:28:37 [DEBUG] Getting items from cache '/home/user/.zotero/cache/items.json'...
18:28:37 [DEBUG] Getting attachments from cache '/home/user/.zotero/cache/attachments.json'...
18:28:37 [DEBUG] Getting notes from cache '/home/user/.zotero/cache/notes.json'...
18:28:37 [DEBUG] Getting annotations from cache '/home/user/.zotero/cache/annotations.json'...
18:28:37 [DEBUG] Opening marks from cache '/home/user/.zotero/cache/marks.json'...
Of course then the cache files are empty, and zotero-cli reset
will delete the files and start from scratch again.
Not a blocker for me. In the README, there is the following example code:
zotero-cli show year title itemType numPages --filter "collections:biblio" --filter "title:detect" --limit ">date:10"
Looks like it has some issues handling the data it has. I get for pages errors if the page is as not an integer.
19:28:30 [WARNING] Bad pages value 'S20'
Dates also fail a lot with the following error:
19:34:24 [WARNING] Bad datetime format: January 1, 2021 for item titled 'XXXX'. Using default date 1900-01-01.
Different time formats that throw errors:
July 1, 2021
2021/11
2021/07/05
2019-07-20T05:00:01
More errors
% zotero-cli show - --query "top-50-most-relevants"
19:28:30 [WARNING] Bad pages value '...'
19:42:12 [WARNING] Bad datetime format: .... for item titled '...'. Using default date 1900-01-01.
... a lot more warnings as the above two ...
Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.10.6/bin/zotero-cli", line 905, in <module>
z.show(args.field, args.filter, args.sort, args.desc, args.limit)
File "/home/user/.pyenv/versions/3.10.6/lib/python3.10/site-packages/tinyscript/preimports/log.py", line 99, in _wrapper
return f(*args, **kwargs)
File "/home/user/.pyenv/versions/3.10.6/lib/python3.10/site-packages/tinyscript/helpers/decorators.py", line 112, in wrapper
return f(*args, **kwargs)
File "/home/user/.pyenv/versions/3.10.6/bin/zotero-cli", line 705, in show
headers, data = self._items(fields, filters, sort, desc, limit)
File "/home/user/.pyenv/versions/3.10.6/bin/zotero-cli", line 484, in _items
dt = set(ZoteroCLI.date(i['data']['date']).timestamp() for i in items.values()) - {dt_zero}
File "/home/user/.pyenv/versions/3.10.6/bin/zotero-cli", line 484, in <genexpr>
dt = set(ZoteroCLI.date(i['data']['date']).timestamp() for i in items.values()) - {dt_zero}
KeyError: 'date'
Hi, I'm wondering if it is possible to import .bibtex file to zotero from command line?
sth like zotero-cli import xxx.bib
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.