Resilient, Zero-Key Shadow Library Downloader CLI & AI Agent
Instant search, multi-mirror recovery, and high-speed streaming for Anna's Archive and Library Genesis (LibGen).
annas-archive • libgen • shadow-library • book-downloader • ebook-downloader • python-cli • ai-agent • claude-code • open-access • research-automation
- 🔓 Zero Paid API Keys Required: No donation keys or membership tokens needed. Operates freely over verified public mirror endpoints.
- 🚀 Ultra Lightweight & Fast: Pure Python core (
requests+ regex). Starts in milliseconds without heavy browser runtimes unless required. - 🛡️ DDoS-Guard & Cloudflare Bypass: Automated fallback with stealth headless Chromium (
--disable-blink-features=AutomationControlled,delete navigator.webdriver) to resolve JS challenges (&check=1) seamlessly when plain HTTP encountersHTTP 403 Forbidden. - 🔄 10-Candidate MD5 Recovery Loop: Never stops at the first broken link. Extracts up to 10 unique MD5 candidates and sequentially probes working download mirrors.
- ⚡ Direct Dynamic Token Extraction (
ads.php→get.php): Extracts ephemeral download tokens on the fly for high-speed streaming. - 🔍 Smart Title Sanitizer: Automatically cleans editions (
(2nd ed.)), annotations, and subtitles, creating progressive 4-tier fallback queries. - 🌐 Built-in DNS Bypass: Monkey-patches socket resolution directly to edge IP (
104.21.34.70) to circumvent regional ISP blocks. - 📖 Dual Format Engine (PDF Default + Opt-in EPUB): Prioritizes full-fidelity complete PDF editions by default while demoting incomplete pamphlets/flyers (< 150 KB). Includes native
--format epubsupport for e-readers (Kobo, Kindle) with automatic magic-byte format validation. - 📄 Dual Agent Toolkit (
bookdl&paperdl): Full support for both books/monographs and academic research papers (preprints, journals, working papers) across arXiv, SSRN, Unpaywall, OpenAlex, MDPI, and Anna's Archive with automated Cloudflare/bot challenge bypass. - 🤖 First-Class AI Agent Interoperability: Built from the ground up with explicit AGENTS.md contracts and exit codes for Claude Code, Gemini CLI, Cursor, Antigravity, OpenCode, and Codex.
flowchart TD
A["User or AI Agent Request<br><code>--title & --author</code>"] --> B["Progressive Query Sanitizer<br>(Strips edition noise, constructs 4 queries)"]
B --> C["Mirror Discovery & Health Check<br>(Probes responsive endpoints)"]
C --> D["Fast Index Discovery<br>(Libgen.li / Anna's Archive)"]
D -- "HTTP 403 / DDoS Challenge" --> E["Stealth Playwright Solver<br>(&check=1 Challenge Resolution)"]
D -- "HTTP 200 OK" --> F["MD5 Candidate Aggregation<br>(Top 10 Unique Hashes)"]
E --> F
F --> G{"Iterate Candidates (1 to 10)"}
G --> H["Dynamic Token Resolution<br>(ads.php -> get.php extraction)"]
H --> I{"Direct Stream Valid?"}
I -- "Yes (Size > 10 KB)" --> J["Save to Disk & Atomic JSON Log [SUCCESS]"]
I -- "No / Dead Mirror" --> G
G -- "All Exhausted" --> K["Record Failure [FAILED]"]
# Clone the repository
git clone https://github.com/nsozturk/anna-dl.git
cd anna-dl
# Install dependencies
pip install -r requirements.txt
# Install CLI tool globally / in active environment
pip install -e .(Optional: For automatic DDoS-Guard JavaScript challenge resolution on direct Anna's Archive endpoints, install Playwright):
pip install playwright
playwright install chromium# Default: High-quality complete PDF format
anna-dl get --title "Atomic Habits" --author "James Clear"
# Prefer reflowable EPUB format for e-readers (Kobo, Kindle)
anna-dl get --title "Atomic Habits" --author "James Clear" --format epub
# Custom search query override
anna-dl get --title "Thinking, Fast and Slow" --query "Kahneman Thinking Fast"
# Bypass regional or ISP DNS censorship
anna-dl get --title "Deep Work" --author "Cal Newport" --bypass-dns
# Custom destination folder
anna-dl get --title "Clean Code" --author "Robert Martin" --output-dir ./library# Download entire books_queue.json sequentially
anna-dl download
# High-throughput multi-threaded download (4 parallel workers)
anna-dl download --parallel --workers 4
# Filter batch by specific category prefixes
anna-dl download --categories 01,02,03
# Re-attempt failed or incomplete books
anna-dl retry --bypass-dnsConvert markdown tables (| Title | Author | Year |) into a clean books_queue.json:
anna-dl extract --docs-dir ./reading-lists/# Verify downloaded files against log
anna-dl sync
# Display overall archive health & counts
anna-dl statusRetrieve academic papers and preprints across arXiv, SSRN, Open Access repositories, and Anna's Archive with automated anti-bot bypass:
# Download by arXiv ID (Open Access)
paperdl get --arxiv 2306.13661 --dest ./papers/2306.13661.pdf
# Download by SSRN Abstract ID (with automatic Chrome bypass if blocked)
paperdl get --ssrn 4857230 --dest ./papers/ssrn_4857230.pdf
# Download by DOI (queries Unpaywall + open university repositories)
paperdl get --doi 10.1016/j.frl.2023.103809 --dest ./papers/paper.pdf
# Download by Direct URL (MDPI, NBER, etc.)
paperdl get --url "https://www.mdpi.com/1911-8074/18/4/201/pdf" --dest ./papers/paper.pdf
# Download by Paper Title (fuzzy multi-source search)
paperdl get --title "Factor Momentum" --dest ./papers/factor_momentum.pdf
# Force Google Chrome native bypass for Cloudflare Turnstile protected sites
paperdl get --ssrn 5209907 --chrome --dest ./papers/crypto_trends.pdf
# Batch download entire research catalog from Markdown file
paperdl md ./research_papers.md --output-dir ./papers/ --workers 4anna-dl includes native root agent instructions (AGENTS.md) and an importable global rule snippet (GLOBAL_AGENT_RULE.md).
Copy GLOBAL_AGENT_RULE.md into your AI environment (~/.claude/agents/anna-dl.md, ~/.config/agent-rules/anna-dl.md, or Cursor project rules) to give your LLM agent autonomous literature lookup capabilities.
Note
annas-archive.org and annas-archive.se were seized in mid-2026. anna-dl automatically maintains the current roster of active, verified working mirrors:
- Anna's Archive:
https://annas-archive.gl(Primary Default),https://annas-archive.pk,https://annas-archive.gd,https://annas-archive.vg - Library Genesis:
libgen.la,libgen.gl,libgen.vg,libgen.is,libgen.rs,libgen.li
- 📄 Academic Research Paper Engine (
paperdl): Integrated multi-tiered research paper retrieval for arXiv, SSRN, DOI, and open access repositories (Unpaywall, OpenAlex). - 🛡️ Native Google Chrome Anti-Bot Driver: macOS AppleScript automation bypassing Cloudflare Turnstile, DDoS-Guard, and Akamai challenges with 100% human-grade trust score.
- ⚡ Unified CLI Console Scripts: Direct access to
paperdlalongsideanna-dlandbookdl.
- ✨ Zero-Key Architecture: Complete multi-mirror search without requiring paid API keys.
- 🛡️ DDoS-Guard Evasion: Stealth headless browser fallback resolving JS tests and
&check=1redirects. - 🔁 10-Candidate Loop: Resilient sequential fallback across top 10 MD5 hashes.
- ⚡ Dynamic Token Extraction: Real-time token acquisition via
ads.php→get.php. - 🔌 Agent Contracts: Full
AGENTS.mdandGLOBAL_AGENT_RULE.mdspecifications.
anna-dl is an educational open-source software project designed for researchers, educators, and archivists to discover and retrieve open-access and public domain scientific literature. The maintainers do not host or distribute copyright-infringing materials. Users are responsible for complying with the local laws of their respective jurisdictions.
Distributed under the MIT License.
