SuperAPI AI Directory

zbook

General & other

View repository

Updated 10-15 22:11

About this skill

zbook

Download any ebook from Z-Library with a single sentence.

Tech stack: Z-Library eapi search + Playwright headless bypasses Cloudflare for downloads
No Telegram bot needed, no extra API key needed, only a Z-Library account.

Usage (say to me)

  • "Help me download 《Atomic Habits》"
  • "Download 三体 epub"
  • "Download Designing Data-Intensive Applications"

Commands

python3 skills/zbook/scripts/zbook.py "书名或作者"
python3 skills/zbook/scripts/zbook.py --format epub --lang en "Atomic Habits"
python3 skills/zbook/scripts/zbook.py --lang zh "三体 刘慈欣"
python3 skills/zbook/scripts/zbook.py --index 1 "深度工作"   # 选第2个结果
python3 skills/zbook/scripts/zbook.py --json "Atomic Habits" # JSON 输出
python3 skills/zbook/scripts/zbook.py --setup                # 首次配置

Configuration

Config file:~/.zbook/config.json

{
  "email": "your@email.com",
  "password": "your_password",
  "download_dir": "~/Downloads/ebooks"
}

Run --setup to enter the interactive configuration wizard.

Cookies are cached in ~/.zbook/cookies.json(valid for 24h), avoiding frequent logins that trigger restrictions.

Dependency installation

pip3 install playwright aiohttp --break-system-packages
python3 -m playwright install chromium

How it works

  1. Login: POST z-library.sk/rpc.php to obtain authentication cookies (cached for 24h)
  2. Search: POST /eapi/book/search, parameter name message, form-urlencoded (note: not q, not JSON)
  3. Sort: sort by scoring language + format preference
  4. Download: Playwright injects cookies, navigates to /dl/xxx to trigger file download (bypassing Cloudflare)

Notes

  • Z-Library free accounts have a daily download limit of 10 books
  • The search parameter name is message(not q), and the format must be application/x-www-form-urlencoded
  • The download endpoint is protected by Cloudflare; pure HTTP requests will get 503, so Playwright must be used
  • Frequent logins will trigger the "Too many logins" restriction; the cookie caching mechanism solves this problem