Jump to content

ZotQuery: an Alfred workflow for Zotero


Recommended Posts

Ha. Well, it can if you store the metadata of your ebooks in Zotero, then link to the actual ebook file from the Zotero item. In that case, you would be able to search your ebooks and open then from ZotQuery.

So, yes, yes it can manage your ebook collection ;D

Link to comment

Now I can't tell where the trolling ends and the laziness begins...

Zotero: https://www.zotero.org/

And I quote:

Zotero is the only research tool that automatically senses content in your web browser, allowing you to add it to your personal library with a single click. Whether you're searching for a preprint on arXiv.org, a journal article from JSTOR, a news story from the New York Times, or a book from your university library catalog, Zotero has you covered with support for thousands of sites.

Zotero collects all your research in a single, searchable interface. You can add PDFs, images, audio and video files, snapshots of web pages, and really anything else. Zotero automatically indexes the full-text content of your library, enabling you to find exactly what you're looking for with just a few keystrokes.

Edited by smarg19
Link to comment

Honestly, it would probably be a good ebook manager. It just requires a little imagination :)

There is a wonderful add-on for Zotero called ZotFile. This would allow you to store all of your ebooks in one directory with a consistent naming convention.

Then, you could use Zotero's killer feature (citation scraping from the web) as an easy way to create a "Wishlist". If you're online and come across an ebook you'd like but don't have, save it to Zotero. Once you've downloaded the actual epub or pdf, use ZotFile to link that file to the proper item (moving it and renaming it automatically). So, all linked items you have books for; all unlinked items are "Wishlist".

Then, you could organize your books into Groups or even use Tags. "Sci-Fi", "Coding", etc.

I think it would work pretty well.

Link to comment

Honestly, it would probably be a good ebook manager. It just requires a little imagination :)

There is a wonderful add-on for Zotero called ZotFile. This would allow you to store all of your ebooks in one directory with a consistent naming convention.

Then, you could use Zotero's killer feature (citation scraping from the web) as an easy way to create a "Wishlist". If you're online and come across an ebook you'd like but don't have, save it to Zotero. Once you've downloaded the actual epub or pdf, use ZotFile to link that file to the proper item (moving it and renaming it automatically). So, all linked items you have books for; all unlinked items are "Wishlist".

Then, you could organize your books into Groups or even use Tags. "Sci-Fi", "Coding", etc.

I think it would work pretty well.

 

I use calibre for ebooks. It's ugly as sin, but so good at what it does.

 

Zotero might be an interesting tool to manage all my ESL materials, however. Will look into it.

Link to comment

Then, you could use Zotero's killer feature (citation scraping from the web) as an easy way to create a "Wishlist". If you're online and come across an ebook you'd like but don't have, save it to Zotero. Once you've downloaded the actual epub or pdf, use ZotFile to link that file to the proper item (moving it and renaming it automatically). So, all linked items you have books for; all unlinked items are "Wishlist".

 

I never liked the manual part of all of that. I wrote a script a while ago to process any pdf ebooks that I had (doesn't work with articles) that just reads through the first 10 pages, grabs an ISBN/EAN then queries Amazon and LOC for the metadata, combines those into a hybrid meta file, and then renames the book. It's saved me so much time.

Link to comment

I never liked the manual part of all of that. I wrote a script a while ago to process any pdf ebooks that I had (doesn't work with articles) that just reads through the first 10 pages, grabs an ISBN/EAN then queries Amazon and LOC for the metadata, combines those into a hybrid meta file, and then renames the book. It's saved me so much time.

Well ZotFile acts automatically as well. You can point it at your Downloads folder and have it link and rename the newest Zotero item and newest download.

But, PDF management is probably the next thing I'm going to cogitate on. I recently finished a Python script to (somewhat) intelligently tell if a PDF is OCR'd. I then threw this into a Hazel rule. But I'm not yet fully happy with my PDF management. I need to find a nice mixture of tags, directories, and flow to put my neurotic mind at rest.

Ps. Skimmer has a script to search for ISBNs, DOIs, or fall back to user selected cap words to launch a Google Scholar search. That's the beginning of another idea I have for automating a shitty part of PDF management for scholars. Hopefully one day I'll finish it.

Pps. I'd love to see that script. And to hear about your PDF management system.

Link to comment

Question for any user:

I am working on the ground-up rewrite of ZotQuery. My goal is to make the workflow faster and cleaner, simpler to support, and just plain better. However, the actual UI won't really change. Except, for some additions to Alfred and the workflow-writing community in general that I want to incorporate. The two I am putting up for suggestion are Large Type and Quick Copy. In any script filter, you can use CMD+L on some item to display some text in Alfred's large text box, or CMD+C on an item to copy text to the clipboard.

So, the question: What should ZotQuery copy to the clipboard for each item, or what should it display? How would this functionality suit your needs best?

Link to comment

Thanks for the great work!

 

Maybe the abstract for the large type? An alternative would be the formated citation. But that is just an idea  I am not sure how that looks. I am always like having settings for these things. Also for the new version: It would be great to have a option to exclude group library items and define the fields searched with 'zot' (I think there already is a setting for that).

Link to comment

Thanks for the great work!

 

Maybe the abstract for the large type? An alternative would be the formated citation. But that is just an idea  I am not sure how that looks. I am always like having settings for these things. Also for the new version: It would be great to have a option to exclude group library items and define the fields searched with 'zot' (I think there already is a setting for that).

Good thought. How about abstract or notes for Large Text (depending on which exists). Also, I will have the ability to alter some of this functionality at the top of the code.

The new version (like the old version) has the ability to limit ZotQuery to only your personal items (excluding all items in Group Libraries). It will theoretically be possible to alter the exact scope of zot, but I would recommend against it. This version will be much faster in searching, so there won't be any need to limit it for speed. And all the old, more specific query scopes will be available. I'm not going to advertise a way to fiddle with that, because it could easily break things.

Also, I will add a simple way to change what Quick Copy does. So hopefully this will be configurable enough to be as helpful as possible for people, but stable enough to not be easily broken.

Link to comment

Damn. I'm just reading thru the old posts. I'm astounded at how buggy this workflow was for so long. I'm getting close to releasing the rewrite tho, and I'm pretty excited. It's faster, it's cleaner, and it's FAR less buggy, but it has all of the same UI.

I just wanted to say, to everyone who's posted and downloaded this workflow, thanks for sticking with me and with ZotQuery. It's been a fun, if bumpy, ride.

Link to comment
  • 2 months later...

Ok. I need a few beta testers for ZotQuery 10.0. This is a complete rewrite of the ZotQuery code base, though it retains the exact same API (so keywords are the same, possible actions are the same). I've been testing it on my machine, but I want to run it through its paces. I have some automated testing that you could run, and then you would also use the workflow for a while so I can get your feedback.

If you are interested, send me a PM.

Link to comment
  • 3 weeks later...

Hi,

 

I'm having a similar problem to an earlier user. Downloaded zotquery and installed the workflow - when i run z:config nothing happens.

 

I'm not as clued up as previous poster to run terminal commands though I did try - the only thing I noticed is the my library directory is directly of my harddrive so:

 

sshd/library/application support     and then no alfred.  

 

If I go to users then its

 

sshd/users/damoeire  then no application support directory. Only an applications directory (and 15-20 other directory's).

 

I only bought Alfred for zotquery! Any advice? thanks,

Damian

Link to comment

Hi,

 

I'm having a similar problem to an earlier user. Downloaded zotquery and installed the workflow - when i run z:config nothing happens.

 

I'm not as clued up as previous poster to run terminal commands though I did try - the only thing I noticed is the my library directory is directly of my harddrive so:

 

sshd/library/application support     and then no alfred.  

 

If I go to users then its

 

sshd/users/damoeire  then no application support directory. Only an applications directory (and 15-20 other directory's).

 

I only bought Alfred for zotquery! Any advice? thanks,

Damian

 

I'm grateful that you think zotquery worth the investment. :)

 

Have you tried to run z:config with Alfred's debugger on for ZotQuery? That would probably give me some helpful clues as to what's wrong. Also, try to do a simple search with the debugger on. Paste those logs here and I'll look them over.

Link to comment

Thanks for replying.

 

Running z:config with debugger

Starting debug for 'ZotQuery'

 

[iNFO: alfred.workflow.input.keyword] Processing output 'alfred.workflow.action.script' with arg ''

 

Anytime I go to search (since I haven't gotten past step one I don't really understand the options yet),

but I type zot for example and alfred shows underneath 'search your zotero library (titles)' and other options, as well as launching zotero, but as soon as I type in another letter (after a space), it goes to search google, amazon or wikipedia.

 

I hope that helps!

Link to comment

Ok. Instead of trying to debug an older version of ZotQuery, I'm going to send you the beta of the new version (TBH I barely remember the code from the old version). This should fix your problem (assuming the problem is what I think it is). The new version will automatically overwrite the old version, so it is super easy to install. Go here and download the .alfredworkflow file: <https://github.com/smargh/alfred_zotquery/releases>.

Then, try to set everything up again.

Link to comment

Oh yeah. I gave it a new bundle_id so that I could develop it alongside the older version. I should change that soon. Basically, you should use it and if it works well for you after you put it through the paces, I'm going to officially release it (then I will need to change the bundle_id to the basic ZotQuery one). 

Link to comment

I can't seen to change my preferences (export style).

 

When I type z:prefs into alfred, nothing happens.

 

Here's the debug from z:prefs

 

 

Starting debug for 'ZotQuery'

 

[ERROR: alfred.workflow.action.script] Code 1: 15:50:39 workflow.py:1457 DEBUG    Stored data loaded from : /Users/Damiennew/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery2/local_zotero.json

15:50:40 workflow.py:1514 DEBUG    Stored data saved at : /Users/Damiennew/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery2/local_zotero.json

15:50:40 workflow.py:1457 DEBUG    Stored data loaded from : /Users/Damiennew/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery2/zotquery_backend.json

15:50:40 workflow.py:2150 DEBUG    Got password : com.hackademic.zotquery2:web_zotero

15:50:40 workflow.py:2044 INFO     Checking for update ...

15:50:40 background.py:180 DEBUG    Command arguments cached to `/Users/Damiennew/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.zotquery2/__workflow_update_check.argcache`

15:50:40 background.py:184 DEBUG    Calling [u'/usr/bin/python', '/Users/Damiennew/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.803FD61C-8B7B-408C-937D-A6271DE66336/workflow/background.pyc', u'__workflow_update_check'] ...

15:50:40 workflow.py:1903 DEBUG    Workflow finished in 0.003 seconds.

15:50:40 workflow.py:1903 DEBUG    Workflow finished in 0.004 seconds.

15:50:40 background.py:189 DEBUG    Executing task `__workflow_update_check` in background...

15:50:40 zotquery.py:95 INFO     - - - NEW RUN - - -

15:50:40 workflow.py:1903 DEBUG    Workflow finished in 0.005 seconds.

Usage:

    zotquery.py configure <flag> [<argument>]

    zotquery.py search <flag> [<argument>]

    zotquery.py store <flag> <argument>

    zotquery.py export <flag> <argument>

    zotquery.py append <flag> <argument>

    zotquery.py open <flag> <argument>

    zotquery.py scan <flag> [<argument>]

Edited by Damoeire
Link to comment

I can't seen to change my preferences (export style).

 

When I type z:prefs into alfred, nothing happens.

 

Here's the debug from z:prefs

 

Starting debug for 'ZotQuery'
 
[ERROR: alfred.workflow.action.script] Code 1: 15:50:39 workflow.py:1457 DEBUG    Stored data loaded from : /Users/Damiennew/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery2/local_zotero.json
15:50:40 workflow.py:1514 DEBUG    Stored data saved at : /Users/Damiennew/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery2/local_zotero.json
15:50:40 workflow.py:1457 DEBUG    Stored data loaded from : /Users/Damiennew/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery2/zotquery_backend.json
15:50:40 workflow.py:2150 DEBUG    Got password : com.hackademic.zotquery2:web_zotero
15:50:40 workflow.py:2044 INFO     Checking for update ...
15:50:40 background.py:180 DEBUG    Command arguments cached to [font=courier new,courier,monospace]/Users/Damiennew/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.zotquery2/__workflow_update_check.argcache[/font]
15:50:40 background.py:184 DEBUG    Calling [u'/usr/bin/python', '/Users/Damiennew/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.803FD61C-8B7B-408C-937D-A6271DE66336/workflow/background.pyc', u'__workflow_update_check'] ...
15:50:40 workflow.py:1903 DEBUG    Workflow finished in 0.003 seconds.
15:50:40 workflow.py:1903 DEBUG    Workflow finished in 0.004 seconds.
15:50:40 background.py:189 DEBUG    Executing task [font=courier new,courier,monospace]__workflow_update_check[/font] in background...
15:50:40 zotquery.py:95 INFO     - - - NEW RUN - - -
15:50:40 workflow.py:1903 DEBUG    Workflow finished in 0.005 seconds.
Usage:
    zotquery.py configure <flag> [<argument>]
    zotquery.py search <flag> [<argument>]
    zotquery.py store <flag> <argument>
    zotquery.py export <flag> <argument>
    zotquery.py append <flag> <argument>
    zotquery.py open <flag> <argument>
    zotquery.py scan <flag> [<argument>]

Thank you for finding this small bug. I actually changed the API, but didn't update all of the workflow's API calls. I will be sure to have this fixed for final release. For you, it's an easy fix. Open the "Run Script" node attached to the z:prefs keyword. In the script text, change /usr/bin/python zotquery.py config prefs into /usr/bin/python zotquery.py configure prefs. So, you are changing "config" into "configure". That will fix the problem.

stephen

Link to comment
  • 2 weeks later...

Thank you for finding this small bug. I actually changed the API, but didn't update all of the workflow's API calls. I will be sure to have this fixed for final release. For you, it's an easy fix. Open the "Run Script" node attached to the z:prefs keyword. In the script text, change /usr/bin/python zotquery.py config prefs into /usr/bin/python zotquery.py configure prefs. So, you are changing "config" into "configure". That will fix the problem.

stephen

Thanks for the fix and sorry for the delay, I don't think I got an email notification and then forgot to check for a reply. That has indeed fixed it, and I did the same thing for z: config option, as that didn't seem to be working either, though I could be mistaken, it works now regardless.

 

A funny thing is happening, when I type some things, (maybe most things, I haven't been using it a great deal, but am bringing into my workflow more often) for example z [enter] smith, it works fine, I get my options, but when I'm typing 'z: olden' I get a 'string out of range' error, then it switches to 'search google, search wiki (also search zotero as the third option, which doesn't work if I choose it) 

Debug is below:

 

Ok, I'm not actually getting anything in the debug window, perhaps because it's not completing an operation? And when it type z: debug, I get:

 

(Ok I'm writing this as I go along, this time I got a debug report, on the z: debug command which is below:)

 

Starting debug for 'ZotQuery'

 

[ERROR: alfred.workflow.input.scriptfilter] Code 1: 02:54:18 workflow.py:1457 DEBUG    Stored data loaded from : /Users/Damiennew/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery2/local_zotero.json

02:54:18 workflow.py:1514 DEBUG    Stored data saved at : /Users/Damiennew/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery2/local_zotero.json

02:54:18 workflow.py:1457 DEBUG    Stored data loaded from : /Users/Damiennew/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery2/zotquery_backend.json

02:54:18 workflow.py:2150 DEBUG    Got password : com.hackademic.zotquery2:web_zotero

02:54:18 workflow.py:2044 INFO     Checking for update ...

02:54:18 background.py:180 DEBUG    Command arguments cached to `/Users/Damiennew/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.zotquery2/__workflow_update_check.argcache`

02:54:18 background.py:184 DEBUG    Calling [u'/usr/bin/python', '/Users/Damiennew/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.803FD61C-8B7B-408C-937D-A6271DE66336/workflow/background.pyc', u'__workflow_update_check'] ...

02:54:18 workflow.py:1903 DEBUG    Workflow finished in 0.003 seconds.

02:54:18 workflow.py:1903 DEBUG    Workflow finished in 0.006 seconds.

02:54:18 background.py:189 DEBUG    Executing task `__workflow_update_check` in background...

02:54:18 zotquery.py:95 INFO     - - - NEW RUN - - -

02:54:18 zotquery.py:106 INFO     Input arguments : [u'search', u'debug']

02:54:18 workflow.py:1888 ERROR    coercing to Unicode: need string or buffer, NoneType found

Traceback (most recent call last):

  File "/Users/Damiennew/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.803FD61C-8B7B-408C-937D-A6271DE66336/workflow/workflow.py", line 1886, in run

    func(self)

  File "zotquery.py", line 108, in main

    res = pd.run(argv)

  File "zotquery.py", line 64, in run

    return method()

  File "zotquery.py", line 69, in search_codepath

    return search.search(self.flag, self.arg, self.wf)

  File "/Users/Damiennew/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.803FD61C-8B7B-408C-937D-A6271DE66336/zotquery/search.py", line 530, in search

    query = config.decode(query)

  File "/Users/Damiennew/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.803FD61C-8B7B-408C-937D-A6271DE66336/workflow/workflow.py", line 2263, in decode

    text = unicode(text, encoding)

TypeError: coercing to Unicode: need string or buffer, NoneType found

02:54:18 workflow.py:1903 DEBUG    Workflow finished in 0.013 seconds.

Link to comment

Ah... This is why this is a beta version :) You've found another bug. And, in addition to that bug, you've actually helped me to see that there's is some functionality that I need to finish (like the z:bug filter). So, there is a bug in the z:bug filter. I will have to update that.

As for the other intermittent problem, I cannot tell what that is. First of all, there are no searches that begin z:[space]anything. So, if you were every typing that, Alfred would fall back to the default searches. However, those default fallbacks would never show an error, so you must have typed something else to get the string out of range error. If you could replicate that with the debugger on, it would be greatly helpful.

Also, feel free to ask me any questions about the API and the functionality. I know the workflow is big and has alot of functionality. If you haven't read my blog post on all that it does, that would probably be helpful.

stephen

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...