jbaiter / zotero-cli

Command-line interface for Zotero
MIT License
274 stars 41 forks source link

Open pdf attachments stored locally #17

Open joelostblom opened 7 years ago

joelostblom commented 7 years ago

Can zotero-cli read pdf-attachments that are not stored on the zotero server? I am using zotfile to organize my pdf articles and I store them in a separate directory on the file system. Zotero stores a link pointing to the location of the pdf, would it be possible to resolve this link with zotero-cli in order to open the pdf?

This is the traceback I am receiving when trying to open a linked pdf-attachemnt with zotcli read <id>

Traceback (most recent call last):
  File "/home/joel/anaconda3/bin/zotcli", line 11, in <module>
    sys.exit(cli())
  File "/home/joel/anaconda3/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/joel/anaconda3/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/joel/anaconda3/lib/python3.5/site-packages/click/core.py", line 1066, ininvoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/joel/anaconda3/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/joel/anaconda3/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/joel/anaconda3/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/joel/anaconda3/lib/python3.5/site-packages/zotero_cli/cli.py", line 198,in read
    attachments = ctx.obj.attachments(item_id)
  File "/home/joel/anaconda3/lib/python3.5/site-packages/zotero_cli/backend.py", line 224, in attachments
    attachments = self._zot.children(item_id, itemType="attachment")
  File "/home/joel/anaconda3/lib/python3.5/site-packages/pyzotero/zotero.py", line 127, in wrapped_f
    retrieved = self._retrieve_data(func(self, *args))
  File "/home/joel/anaconda3/lib/python3.5/site-packages/pyzotero/zotero.py", line 557, in children
    i=item.upper())
AttributeError: 'NoneType' object has no attribute 'upper'
DancingQuanta commented 7 years ago

The error handling is better now, saying that attachment is not stored on server. HEAD have local storage and so need to add code that stores link to file in index.sqlite and use that to open locally stored pdf.

kevintaylor commented 6 years ago

+1 for this feature request.

jakub-kaminski commented 5 years ago

+1 for this feature request.

eomiso commented 3 years ago

+1 for this feature request.