Zotero to Sioyek Highlights Manager
Python script to embed zotero highlights to sioyek, and other utils.
📖 Contents
- ✨ Features
- 📚 Requirements
- 🐍 Conda
- 📦 Installation
- 🔧 Configuration
- 🎨 Colors
- 💻 Client
- 📝 TODO
- 🤝 Contributing
- 💓 Aknowledgements
✨ Features
- Embed zotero highlights to the sioyek database:
python zot2sioyek.py --insert-highlights "/path/to/file.pdf"
- Print in terminal the text of all the highlights from a zotero file, colored with the highlight color
python zot2sioyek.py --print-annotation-text "/path/to/file.pdf"
- To see all available commands:
python zot2sioyek.py --help
- For testing the package through pytest
python -m pytest --doctest-modules tests/test.py src/zot2sioyek/zot2sioyek.py
📚 Requirements
Requirements are automatic installed when this script is installed with pip
-
pyzotero
-
pymupdf
-
PyQt5
-
regex
-
sqlite3
python -m pip install pyzotero pymupdf PyQt5 regex sqlite3
🐍 Conda
If wanted, requirements may be installed with conda, to run this script in a conda environment.
Inside this repo, run:
conda env create --file env.yml
📦 Installation
To run the script without installation, simply clone the repo or download /src/zot2sioyek/zot2sioyek.py and run it directly.
Default installation is done by
python -m pip install zot2sioyek
Being possible after install to run the comman with zot2sioyek in terminal.
Other possible approach to install is cloning the repo and installing locally
git clone https://github.com/eduardotlc/zot2sioyek
cd zot2sioyek
python -m pip install -e .
🔧 Configuration
To use this script define the variables in zot2sioyek.py:
-
SIOYEK_PATH: Sioyek binary path. -
SIOYEK_LOCAL_DATABASE_FILE_PATH: Sioyek .db local database file path. -
SIOYEK_SHARED_DATABASE_FILE_PATH: Sioyek .db shared database file path. -
ZOTERO_LIBRARY_ID: Your personal library ID available Here, in the section Your userID for use in API calls. -
ZOTERO_API_KEY: Api key, you can obtain Here. -
ZOTERO_LIBRARY_TYPE: Zotero library type, can be'user'or'group'. -
ZOTERO_LOCAL_DIR: Zotero local storage folder, like/home/user/Zotero/storage. -
ZOTERO_TO_SIOYEK_COLORS: Sioyek highlight type letter associated to each zotero highlight color (Optional).
🎨 Colors
- This script defines
ZOTERO_TO_SIOYEK_COLORSvariable based on the most close colors of default sioyek config, to the zotero highlight colors. The conversion looks like the following (Zotero colors in the upper row, sioyek colors in the lower row):
- If you want to have the exact same colors of zotero highlights in sioyek, add the following to
your sioyek
prefs_user.config:
highlight_color_g 0.37 0.70 0.21
highlight_color_a 0.63 0.54 0.90
highlight_color_p 0.90 0.43 0.93
highlight_color_b 0.18 0.66 0.90
highlight_color_r 1.00 0.40 0.40
highlight_color_o 0.95 0.60 0.22
highlight_color_y 1.00 0.83 0.00
- Or to any highlight letter you want, since the defined letter on
prefs_user.configand the script variableZOTERO_TO_SIOYEK_COLORSmatch.
💻 Client
The following commands are available through:
In a local folder after downloading the script, cd in /src/zot2sioyek and run
python zot2sioyek.py [FLAG] [ARGS]
If installed through pip or through cloning or with pip install -e . in the repo root, the 2
following commands are available
python -m zot2sioyek.zot2sioyek [FLAG] [ARGS]
zot2sioyek [FLAG] [ARGS]
FLAGS ARGUMENTS
===== ==========
Script general utils.
----------------------
-h, --help
Print this script help.
If a Group name is passed after --help, the help to this specific group is printted
only. Available groups are: general, zotero, sioyek.
Zotero Managing Commands.
--------------------------
-g, --get-highlights [file_name_or_path]
Print all highlights from a given zotero file.
-p, --print-annotation-text [file_name_or_path]
print all highlighted text for a given zotero PDF local file.
-T, --zotero-tags [file_name_or_path]
Prints a zotero PDF attachment parent item existing arguments.
-A, --add-zotero-tag [file_name_or_path], [tag_str_to_add]
Add a tag to a zotero PDF attachment parent item. Takes arguments file name or
path, and tag str to add.
-R, --remove-zotero-tag [file_name_or_path], [tag_str_to_remove]
Remove a tag from a zotero PDF attachment parent item. Takes arguments file name or
path, and tag str to remove.
Sioyek Main Commands.
----------------------
-f, --list-sioyek-files
Print all files in sioyek local database
-H, --list-sioyek-hash [file_name_or_path]
print a sioyek database pdf file md5sum hash.
-l, --print-sioyek-attributes [file_name_or_path]
Print all Attributes and values in a sioyek database PDF file.
-i, --insert-highlight [file_name_or_path]
Insert highlights in a sioyek database PDF file, importing this highlights from this
PDF file zotero attachment highlight.
-d, --insert-dated-highlight [datetime.datetime]
Insert highlights in multiple sioyek database PDF files, importing this highlights from this
based on the passed arguments of a datetime.datetime date, to start from to search
for highlights, limit_number_items, that sets the maximum of items to retrieve, and
sort method that organize the order of the retrieved items.
-S, --list-all-sioyek-highlights
Print all sioyek highlights
-k, --citation_key [file_name_or_path]
Print zotero PDF file parent citation key.
Extra options flags.
---------------------
--sort [pyzotero_sort_strategy]
Pyzotero items sorting method. Requires to have passed --insert-dated-highlight.
If an argument passed after a flag contain blank spaces, remember to quote wrap it,
while not being necessary case inputted after through prompted option.
Author: eduardotcampos@usp.br
Zotero Commands
The here examples to the zotero group command flags, were runned considering a local PDF file, that is also added to the zotero database, containing 3 differenct color highlights, that where added through zotero app.
Get Highlights
-g --get-highlights
zot2sioyek -g "/home/eduardotc/Zotero/storage/E5M6X2IH/green ultrafast one-pot mechanochemical bio catalyst encapsulation in MO.pdf"
1
-----
Text: water-based conditions to maintain enzymatic activity due to the inherent fragility
Color: #f19837
Relative Page: 2
Doc Page: 2
Creation Date: 2024-09-08 05:56:08
Modification Date: 2024-09-08 05:56:08
2
-----
Text: Biocatalysts, including enzymes, which are functional proteins known for their outstanding catalytic efficiency, specificity, and selectivity, ha
ve been greatly studied for both research purposes and industrial applications
Color: #a28ae5
Relative Page: 2
Doc Page: 2
Creation Date: 2024-09-08 05:54:42
Modification Date: 2024-09-08 05:54:42
3
-----
Text: well-defined 3D structure of enzyme@ZIF-90 crystals during ultrafast milling reactions. We further demonstrated
Color: #5fb236
Relative Page: 2
Doc Page: 2
Creation Date: 2024-09-08 05:54:35
Modification Date: 2024-09-08 05:54:35
Print Annotation Text
-p --print-annotation-text
water-based conditions to maintain enzymatic activity due to the inherent fragility
Biocatalysts, including enzymes, which are functional proteins known for their outstanding catalytic efficiency, specificity, and selectivity, have been greatly studied for both research purposes and industrial applications
well-defined 3D structure of enzyme@ZIF-90 crystals during ultrafast milling reactions. We further demonstrate
Zotero Tags
-T --zotero-tags
zot2sioyek -T "/home/eduardotc/Zotero/storage/E5M6X2IH/green ultrafast one-pot mechanochemical bio catalyst encapsulation in MO.pdf"
Biological, Catalysis, Encapsulating, MOF, Mechanochemistry, Synthesis, Unread, ⭐️⭐️
Add Zotero Tag
-A --add-zotero-tag
zot2sioyek -A "/home/eduardotc/Zotero/storage/E5M6X2IH/green ultrafast one-pot mechanochemical bio catalyst encapsulation in MO.pdf" Testing
Tag Testing added to PDF parent item.
Remove Zotero Tag
-R --remove-zotero-tag
zot2sioyek -R "/home/eduardotc/Zotero/storage/E5M6X2IH/green ultrafast one-pot mechanochemical bio catalyst encapsulation in MO.pdf" Testing
Tag Testing removed from item.
Sioyek
List Sioyek Files
-f --list-sioyek-files
zot2sioyek -f
f607f555da6ff4f2beb80653e9b07723 : /home/eduardotc/Zotero/storage/HN3SF8WA/Quiroz et al. - 2018 - Controlling Reaction Selectivity over Hybrid Plasmonic Nanocatalysts.pdf
304ca2c74cdfdc66e70098442fb5f75c : /home/eduardotc/Zotero/storage/L9PG5ZKI/Kolemen et al. - 2016 - Remote-Controlled Release of Singlet Oxygen by the.pdf
8b2479fdeaf3261f6de4804c4c2995bc : /home/eduardotc/Zotero/storage/R9RLP4UW/Supporting_MOF_anthracene_singlet.pdf
bfc2bac356c35a457f660a63e8d1ae77 : /home/eduardotc/Zotero/storage/9HAKQCTN/Vijayakumar - 2023 - Cancer targeted contrast studies and photothermal therapy using engineered gold nanoparticles.pdf
303185f111afbd8452b5194b58d00244 : /home/eduardotc/output.pdf
List Sioyek Hash
-H --list-sioyek-hash
zot2sioyek -H "/home/eduardotc/Zotero/storage/HN3SF8WA/Quiroz et al. - 2018 - Controlling Reaction Selectivity over Hybrid Plasmonic Nanocatalysts.pdf"
f607f555da6ff4f2beb80653e9b07723
zot2sioyek -H "/home/eduardotc/Zotero/storage/HN3SF8WA/Quiroz et al. - 2018 - Controlling Reaction Selectivity over Hybrid Plasmonic Nanocatalysts.pdf"
f607f555da6ff4f2beb80653e9b07723
📝 TODO
-
Embed all zotero database highlights starting from a specified date.
-
Create import from sioyek database to zotero database highlights.
- Currently, I couldn't find a way of adding zotero highlights through pyzotero, or through zotero api/sql. If anyone knows how to do it, please message or email me so that I can update this script, or feel free to implement the needed updates and send a pull request, I'll be very thankful.
🤝 Contributing
Feel free to make pending or other optimizations and pull requests, this script is still under development and any contribution is very much appreciated.
- Clone the repo to your local environment:
💓 Aknowledgements
Metadata
Release files for zot2sioyek 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zot2sioyek-0.4.1.tar.gz | 2.3 MB | Without provenance | Details for zot2sioyek-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zot2sioyek-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for zot2sioyek-0.4.1-py3-none-any.whl |
Total release size: 2.3 MB
Release files / zot2sioyek-0.4.1.tar.gz
| Download URL | zot2sioyek-0.4.1.tar.gz |
|---|---|
| Size | 2.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04bc5a8fd732c04688321f76b7f5b706f4dad060d3dcf56797779cbeb241ba99
|
|
BLAKE2b-256 checksum How to use checksums |
17f657326eec5193e041d3b1fcc0fbbb94962db06a44081860eebb473d340415
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Release files / zot2sioyek-0.4.1-py3-none-any.whl
| Download URL | zot2sioyek-0.4.1-py3-none-any.whl |
|---|---|
| Size | 28.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c6fa0b07c1ddf0ac922e706a2a680254846a7cc0405ccb7a5470c695a1901f95
|
|
BLAKE2b-256 checksum How to use checksums |
72ea9a3036223bf9dd6dd80978e23aeac98b2add2baf9cc9a8a8853417f2d1d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Security for zot2sioyek 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.