Update setup instructions for uv and remove requirements.txt

This commit is contained in:
Mantao Huang 2026-03-08 00:30:00 -06:00
parent f949795f71
commit 7e0edaff80
2 changed files with 9 additions and 12 deletions

View File

@ -11,22 +11,21 @@ This script elegantly solves the problem by:
2. Unpacking it from its `.crx` format. 2. Unpacking it from its `.crx` format.
3. Launching Chromium using Playwright in `--headless=new` mode (which DOES allow extensions, unlike the old headless mode) with a persistent user data directory. 3. Launching Chromium using Playwright in `--headless=new` mode (which DOES allow extensions, unlike the old headless mode) with a persistent user data directory.
4. Auto-closing setup tabs. 4. Auto-closing setup tabs.
5. Emulating the official Zotero Connector keyboard shortcut (e.g. `Cmd+Shift+S` on Mac) once the page is fully loaded. 5. Invoking the Zotero Connector programmatically by accessing its background service worker (`Zotero.Connector_Browser.saveWithTranslator(...)`).
## Prerequisites ## Prerequisites
1. **Python 3.8+** installed. 1. [**uv**](https://github.com/astral-sh/uv) installed.
2. **Zotero Desktop** must be currently running on your machine (the extension communicates with the Zotero desktop app securely on port `1969`). 2. **Zotero Desktop** must be currently running on your machine (the extension communicates with the Zotero desktop app securely on port `1969`).
## Setup ## Setup
First, initialize your virtual environment and install dependencies: First, install dependencies and set up the playwright environment using `uv`:
```bash ```bash
python3 -m venv venv uv sync
source venv/bin/activate uv run playwright install chromium
pip install -r requirements.txt
playwright install chromium
``` ```
## Usage ## Usage
@ -34,17 +33,16 @@ playwright install chromium
Simply pass the URL of the paper you want to add to Zotero: Simply pass the URL of the paper you want to add to Zotero:
```bash ```bash
source venv/bin/activate uv run zotero_automator.py "https://arxiv.org/abs/1706.03762"
python zotero_automator.py "https://arxiv.org/abs/1706.03762"
``` ```
If you want to watch the browser process visually (helpful for debugging if a site requires a captcha or login, or just to verify the extension is working), pass the `--headed` flag: If you want to watch the browser process visually (helpful for debugging if a site requires a captcha or login, or just to verify the extension is working), pass the `--headed` flag:
```bash ```bash
python zotero_automator.py "https://arxiv.org/abs/1706.03762" --headed uv run zotero_automator.py "https://arxiv.org/abs/1706.03762" --headed
``` ```
## How It Works ## How It Works
- **`setup_extension()`**: Locates the `EKHAGK...` identifier for the Zotero extension on the Chrome web store and downloads the raw `.crx` payload. It unpacks the contents into `./zotero_extension/`. - **`setup_extension()`**: Locates the `EKHAGK...` identifier for the Zotero extension on the Chrome web store and downloads the raw `.crx` payload. It unpacks the contents into `./zotero_extension/`.
- **`save_to_zotero()`**: Starts an `async_playwright` session pointing to a local profile folder (`./chrome_profile/`). The extension injects its translator scripts on network idle. We fire the platform-specific shortcut for "Save to Zotero" and wait 10 seconds for the backend download to finish. - **`save_to_zotero()`**: Starts an `async_playwright` session pointing to a local profile folder (`./chrome_profile/`). The extension injects its translator scripts on network idle. We find the extension's background service worker, trigger the programmatic save, and then poll `sessionProgress` until Zotero finishes downloading the PDFs and metadata.

View File

@ -1 +0,0 @@
playwright==1.42.0