zlib-download
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBook Tools
书籍工具
Search and download books from multiple sources through a unified CLI.
通过统一的CLI从多个来源搜索和下载书籍。
Backends
后端源
| Backend | Source | Auth Required | Best For |
|---|---|---|---|
| zlib | Z-Library (EAPI) | Email + Password | Largest catalog, direct download |
| annas | Anna's Archive | API Key (donation) | Aggregated sources, multiple mirrors |
| 后端源 | 来源 | 是否需要认证 | 最佳适用场景 |
|---|---|---|---|
| zlib | Z-Library (EAPI) | 邮箱 + 密码 | 最大的目录库,支持直接下载 |
| annas | Anna's Archive | API密钥(需捐赠获取) | 聚合来源,多镜像站点 |
First-Time Setup
首次设置
On first invocation, run the setup check and guide the user through configuration interactively.
首次调用时,运行设置检查并引导用户交互式完成配置。
Step 1: Check Dependencies
步骤1:检查依赖
bash
bash ${SKILL_PATH}/scripts/setup.sh checkOutput is key=value pairs. Check each:
| Key | OK | Missing Action |
|---|---|---|
| | Python 3 not found — user must install it |
| | Run |
| | Run |
bash
bash ${SKILL_PATH}/scripts/setup.sh check输出为键值对形式。检查以下各项:
| 键 | 正常状态 | 缺失时的操作 |
|---|---|---|
| | 未找到Python 3 — 用户需要安装它 |
| | 运行 |
| | 运行 |
Step 2: Configure Credentials
步骤2:配置凭据
Credentials are stored in . Create the file from the skill's bundled template:
~/.claude/book-tools/.envbash
mkdir -p ~/.claude/book-tools
cp ${SKILL_PATH}/scripts/.env.example ~/.claude/book-tools/.envThe file looks like this:
.envundefined凭据存储在 中。从技能附带的模板创建该文件:
~/.claude/book-tools/.envbash
mkdir -p ~/.claude/book-tools
cp ${SKILL_PATH}/scripts/.env.example ~/.claude/book-tools/.env.envundefinedZ-Library credentials
Z-Library凭据
ZLIB_EMAIL=your_email@example.com
ZLIB_PASSWORD=your_password_here
ZLIB_EMAIL=your_email@example.com
ZLIB_PASSWORD=your_password_here
Anna's Archive (optional, requires donation for API key)
Anna's Archive(可选,需捐赠获取API密钥)
ANNAS_SECRET_KEY=your_api_key_here
ANNAS_SECRET_KEY=your_api_key_here
**IMPORTANT**: Do NOT ask the user for credentials directly in chat. Instead:
1. Create the `.env` file (or `.env.example` template)
2. Tell the user to edit `~/.claude/book-tools/.env` with their credentials
3. Wait for the user to confirm they've filled it in
4. Then proceed with search
Alternatively, credentials can be set via CLI (less recommended — visible in shell history):
```bash
python3 ${SKILL_PATH}/scripts/book.py config set --zlib-email "user@mail.com" --zlib-password "password"
**重要提示**:不要在聊天中直接向用户索要凭据。正确步骤:
1. 创建 `.env` 文件(或 `.env.example` 模板)
2. 告知用户编辑 `~/.claude/book-tools/.env` 填入他们的凭据
3. 等待用户确认已填写完毕
4. 然后继续搜索操作
或者,也可以通过CLI设置凭据(不推荐 — 会在Shell历史中可见):
```bash
python3 ${SKILL_PATH}/scripts/book.py config set --zlib-email "user@mail.com" --zlib-password "password"Step 3: Verify
步骤3:验证
bash
python3 ${SKILL_PATH}/scripts/book.py setupExpected output when Z-Library is configured:
json
{
"zlib": { "requests_installed": true, "configured": true },
"annas": { "binary_found": true, "api_key_configured": false }
}If is , the skill is ready to use.
configuredtruebash
python3 ${SKILL_PATH}/scripts/book.py setup当Z-Library配置完成后,预期输出:
json
{
"zlib": { "requests_installed": true, "configured": true },
"annas": { "binary_found": true, "api_key_configured": false }
}如果 为 ,则技能已准备就绪。
configuredtrueCredential Storage Details
凭据存储详情
Two sources are merged ( values take priority):
.env| Source | Path | Format |
|---|---|---|
| | |
| Config JSON | | JSON (auto-managed) |
On first successful Z-Library login, remix tokens are cached in — subsequent calls skip the email/password login and use tokens directly.
config.json会合并两个来源的配置( 中的值优先级更高):
.env| 来源 | 路径 | 格式 |
|---|---|---|
| | 每行 |
| 配置JSON | | JSON(自动管理) |
首次成功登录Z-Library后,remix令牌会缓存到 中 — 后续调用会跳过邮箱/密码登录,直接使用令牌。
config.jsonWorkflow
工作流程
The typical flow is: search → pick → download.
典型流程为:搜索 → 选择 → 下载。
1. Search
1. 搜索
bash
undefinedbash
undefinedAuto-detect backend (tries zlib first, then annas)
自动检测后端源(先尝试zlib,再尝试annas)
python3 ${SKILL_PATH}/scripts/book.py search "machine learning" --limit 10
python3 ${SKILL_PATH}/scripts/book.py search "machine learning" --limit 10
Z-Library with filters
带筛选条件的Z-Library搜索
python3 ${SKILL_PATH}/scripts/book.py search "deep learning" --source zlib --lang english --ext pdf --limit 5
python3 ${SKILL_PATH}/scripts/book.py search "deep learning" --source zlib --lang english --ext pdf --limit 5
Anna's Archive
Anna's Archive搜索
python3 ${SKILL_PATH}/scripts/book.py search "reinforcement learning" --source annas
python3 ${SKILL_PATH}/scripts/book.py search "reinforcement learning" --source annas
Chinese books
中文书籍搜索
python3 ${SKILL_PATH}/scripts/book.py search "莱姆 索拉里斯" --source zlib --lang chinese --limit 5
**Output** (JSON to stdout):
```json
{
"source": "zlib",
"count": 5,
"books": [
{
"source": "zlib",
"id": "12345",
"hash": "abc123def",
"title": "Deep Learning",
"author": "Ian Goodfellow",
"year": "2016",
"language": "english",
"extension": "pdf",
"filesize": "22.5 MB"
}
]
}python3 ${SKILL_PATH}/scripts/book.py search "莱姆 索拉里斯" --source zlib --lang chinese --limit 5
**输出**(标准输出为JSON格式):
```json
{
"source": "zlib",
"count": 5,
"books": [
{
"source": "zlib",
"id": "12345",
"hash": "abc123def",
"title": "Deep Learning",
"author": "Ian Goodfellow",
"year": "2016",
"language": "english",
"extension": "pdf",
"filesize": "22.5 MB"
}
]
}2. Present Results to User
2. 向用户展示结果
After searching, present results as a numbered table so the user can pick:
| # | Title | Author | Year | Format | Size |
|---|-------|--------|------|--------|------|
| 1 | Deep Learning | Ian Goodfellow | 2016 | pdf | 22.5 MB |
| 2 | ... | ... | ... | ... | ... |If results span multiple languages or editions, group them by language or category with sub-headings for clarity.
Ask: "Which book would you like to download? (number)"
搜索完成后,将结果以编号表格形式展示,方便用户选择:
| 序号 | 书名 | 作者 | 年份 | 格式 | 大小 |
|---|-------|--------|------|--------|------|
| 1 | Deep Learning | Ian Goodfellow | 2016 | pdf | 22.5 MB |
| 2 | ... | ... | ... | ... | ... |如果结果包含多种语言或版本,按语言或类别分组,并添加子标题以确保清晰。
询问用户:“你想要下载哪本书?(请输入序号)”
3. Download
3. 下载
bash
undefinedbash
undefinedZ-Library download (needs id + hash from search results)
Z-Library下载(需要搜索结果中的id和hash)
python3 ${SKILL_PATH}/scripts/book.py download --source zlib --id 12345 --hash abc123def -o ~/Downloads/
python3 ${SKILL_PATH}/scripts/book.py download --source zlib --id 12345 --hash abc123def -o ~/Downloads/
Anna's Archive download (needs MD5 hash from search results)
Anna's Archive下载(需要搜索结果中的MD5哈希值)
python3 ${SKILL_PATH}/scripts/book.py download --source annas --hash a1b2c3d4e5 --filename "deep_learning.pdf" -o ~/Downloads/
**Output**:
```json
{
"source": "zlib",
"status": "ok",
"path": "/Users/user/Downloads/Deep Learning (Ian Goodfellow).pdf",
"size": 23592960
}python3 ${SKILL_PATH}/scripts/book.py download --source annas --hash a1b2c3d4e5 --filename "deep_learning.pdf" -o ~/Downloads/
**输出**:
```json
{
"source": "zlib",
"status": "ok",
"path": "/Users/user/Downloads/Deep Learning (Ian Goodfellow).pdf",
"size": 23592960
}4. Report to User
4. 向用户反馈结果
After download, report:
- File path (so user can open it)
- File size
- Any remaining download quota (Z-Library has daily limits)
下载完成后,反馈以下信息:
- 文件路径(方便用户打开)
- 文件大小
- 剩余下载配额(Z-Library有每日限制)
Other Commands
其他命令
Book Info (Z-Library only)
书籍信息(仅Z-Library支持)
bash
python3 ${SKILL_PATH}/scripts/book.py info --source zlib --id 12345 --hash abc123defReturns full metadata: description, ISBN, pages, table of contents, etc.
bash
python3 ${SKILL_PATH}/scripts/book.py info --source zlib --id 12345 --hash abc123def返回完整元数据:描述、ISBN、页数、目录等。
Check Config
查看配置
bash
python3 ${SKILL_PATH}/scripts/book.py config showbash
python3 ${SKILL_PATH}/scripts/book.py config showCheck Backend Status
检查后端源状态
bash
python3 ${SKILL_PATH}/scripts/book.py setupbash
python3 ${SKILL_PATH}/scripts/book.py setupError Handling
错误处理
| Error | Cause | Action |
|---|---|---|
| "Z-Library not configured" | No credentials | Guide user to edit |
| "Z-Library login failed" | Bad credentials or service down | Ask user to verify credentials. Z-Library domains change — if persistent, the vendored |
| "annas-mcp binary not found" | Binary not installed | Run |
| "Anna's Archive API key not configured" | No API key | Guide user to donate at Anna's Archive for API access, then add key to |
| Search timeout | Network issue | Retry once. If persistent, try the other backend. |
| "No backend available" | Neither backend configured | Walk through full setup flow from Step 1 |
| 错误信息 | 原因 | 处理操作 |
|---|---|---|
| "Z-Library not configured" | 无凭据 | 引导用户编辑 |
| "Z-Library login failed" | 凭据错误或服务不可用 | 请用户验证凭据。Z-Library域名会变化 — 如果问题持续,可能需要更新内置的 |
| "annas-mcp binary not found" | 未安装二进制文件 | 运行 |
| "Anna's Archive API key not configured" | 无API密钥 | 引导用户前往Anna's Archive捐赠获取API访问权限,然后将密钥添加到 |
| 搜索超时 | 网络问题 | 重试一次。如果问题持续,尝试切换到另一个后端源。 |
| "No backend available" | 两个后端源均未配置 | 引导用户从步骤1开始完成完整的设置流程 |
Tips
小贴士
- Z-Library has a daily download limit (usually 10/day for free accounts). Use to check a book before downloading to avoid wasting quota.
info - Anna's Archive requires an API key for both search and download (obtained via donation).
- For Chinese books, use with Z-Library for best results.
--lang chinese - If Z-Library is unreachable, automatically fall back to Anna's Archive with .
--source auto - When searching for a specific author in multiple languages, run parallel searches (e.g. English name + Chinese name) and merge results into one table.
- Z-Library有每日下载限制(免费账户通常为10本/天)。下载前使用命令查看书籍信息,避免浪费配额。
info - Anna's Archive的搜索和下载都需要API密钥(需捐赠获取)。
- 对于中文书籍,在Z-Library中使用参数可获得最佳结果。
--lang chinese - 如果Z-Library无法访问,使用参数会自动回退到Anna's Archive。
--source auto - 当搜索多语言的特定作者时,可并行搜索(例如英文名 + 中文名),并将结果合并到一个表格中。