$ show guaguastandup/zotero-pdf2zh
zotero-pdf2zh is an application consisting of a Zotero plugin (TypeScript) and a companion Python Flask server that together enable in-place PDF translation within Zotero. The plugin adds a right-click menu to Zotero items — Translate, Crop, Compare, Crop-Compare — and communicates with the local server via HTTP. The server manages a dedicated Python virtual environment (using uv or conda) that runs either the legacy `pdf2zh` or the recommended `pdf2zh_next` CLI translation engine. The server exposes REST endpoints for translation, cropping, comparison, file download, and SSE-based progress tracking, and supports over 20 LLM translation services (OpenAI, DeepSeek, Gemini, etc.) via user-configured API keys. The system includes Docker deployment, Windows/macOS automation (monitors, right-click scripts), auto-updates, and a bilingual VitePress documentation site. Despite being primarily a software application, it has a strong data-processing character in its PDF manipulation and LLM orchestration layers, but the overall architecture is clearly a client-server addon, not a data analytics project.
The LLM identified 3 files worth highlighting for reuse:
Implements PDF cropping (splitting double-column pages) and side-by-side compare layouts using PyMuPDF. Contains dual-column detection (left/right or top/bottom), redaction-based clipping, and merge logic for building LR/TB compare images. The core functions are self-contained, depend only on PyMuPDF and standard libraries, and could be extracted into any PDF manipulation project. Demonstrates non-obvious skill in PDF coordinate geometry and layout reconstruction.
Probes multiple PyPI indexes and mirrors (official, USTC, TUNA, Aliyun) concurrently using ThreadPoolExecutor, measures index and artifact latency, ranks usable mirrors, and redacts proxy credentials. This is a self-contained utility that solves the recurrent problem of finding a fast, reliable package index in restricted network environments. Minimal internal dependencies (likely only logger configuration) make it extractable for any Python project that needs intelligent package mirror selection.
Handles DeepSeek V4 thinking mode and reasoning effort configuration by probing the installed pdf2zh_next runtime capability (via distribution metadata or --help). Normalizes flags for different CLI versions, strips unsupported fields from old runtimes, and blocks the feature on unsupported platforms (e.g., Windows exe). This pattern of statically probing package metadata to determine feature support without importing heavy modules is broadly reusable for version-gated functionality in Python tools.