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

change zotero://select/items/key to zotero://open-pdf/library/items/key #30

Open
ljci opened this issue Apr 1, 2024 · 1 comment
Open

Comments

@ljci
Copy link

ljci commented Apr 1, 2024

Hi
I just want to modify the zotero://select/items/key to zotero://open-pdf/library/items/key so that I can open PDF in Zotero with zot file_name, not only select the file in zotero but open them in zotero?

I do modified the code in zh.py and remove the prefix "1_" but I fount the "key" which is index code in alfred workflow deubgger is different from the real index code in zotero. Be more specifically, the index code in zotero is something like 7SDEUXN, while the index code with removed prefix in alfred workflow is something SOEJ2DS, which doesn't match.

So I am wondering how you index the index code from zotero
Thank you

@zrfisher
Copy link

zrfisher commented May 9, 2024

Add this function above do_search

def get_pdf_id(e):
    if not e:
        return None
    
    if not e.attachments:
        return None

    atts = e.attachments[:]
    pdf_ids = []
    for att in atts:
        if att.path and att.path[-4:] == ".pdf":
            pdf_ids.append(att.key)

    if len(pdf_ids) == 1:
        return pdf_ids[0]
    else:
        return None

change the url line to

pdf_key = get_pdf_id(e)
url = u'zotero://open-pdf/library/items/' + pdf_key if pdf_key else u'zotero://select/items/' + key```

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

2 participants