home / skills / openclaw / skills / book-fetch

book-fetch skill

/skills/zerone0x/book-fetch

This skill downloads ebooks from Anna's Archive in pdf or epub and uploads them to MEGA, automating library building.

npx playbooks add skill openclaw/skills --skill book-fetch

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
1.6 KB
---
name: book-fetch
description: Download ebooks (epub/pdf) from Anna's Archive and upload them to MEGA automatically. Use when the user asks to download a book, find an ebook, search for a title on Anna's Archive/libgen, or add a book to their MEGA library.
---

# book-fetch

Search Anna's Archive, download epub/pdf, upload to `mega:/Books/`.

## Setup (one-time)

Anna's Archive is DNS-blocked on the VPS. The `/etc/hosts` override is already in place:
```
186.2.165.77 annas-archive.li
```
MEGA is configured via rclone (`rclone ls mega:/` to verify).

## Usage

```bash
cd ~/clawd
.venv-books/bin/python3 skills/book-fetch/scripts/book_fetch.py "TITLE AUTHOR"
```

Options:
- `--format pdf` — prefer PDF over epub
- `--dry-run` — search only, no download
- `--pick -1` — interactive result picker
- `--pick N` — pick result index N (default: 0)

## Download Pipeline

1. Search `annas-archive.li` → parse `data-content` attributes for title/author/md5
2. Fetch `annas-archive.li/md5/<md5>` → find `libgen.li/ads.php` link
3. Fetch `libgen.li/ads.php` → extract `get.php?md5=...&key=...` direct link
4. Download file with progress bar
5. Upload via `rclone copy ... mega:/Books/`

**Fallback:** If no libgen.li mirror exists (newer books), tries Anna's Archive fast/slow download links.

## Notes

- New books (2023+) may lack libgen mirrors; fast_download requires AA membership; slow_download is rate-limited
- venv: `~/clawd/.venv-books/` (requests, beautifulsoup4, lxml)
- Files cached at `/tmp/books/` after download
- GitHub: <https://github.com/zerone0x/book-fetch>

Overview

This skill automates finding and fetching ebooks (EPUB/PDF) from Anna's Archive and mirrors them into a MEGA folder. It searches Anna's Archive (and LibGen mirrors when available), downloads the selected file, and uploads it to mega:/Books/ using rclone. It supports format preference, interactive picking, and a dry-run search mode.

How this skill works

The skill scrapes Anna's Archive search results to extract title, author, and MD5 identifiers. It follows MD5 links to locate LibGen mirror download endpoints or Anna's Archive fast/slow download links, downloads the file with a progress indicator, caches the file in /tmp/books/, and uploads it to MEGA via rclone copy. If LibGen mirrors are missing, the script falls back to Anna's Archive downloads and handles membership/rate-limit differences.

When to use it

  • You want an automated way to add a specific ebook to your MEGA library.
  • You need to search Anna's Archive or LibGen for a particular title or author.
  • You prefer a command-line tool with format preference (epub/pdf) and result selection.
  • You want to batch or scripted downloads with automatic upload to mega:/Books/
  • You need a dry-run mode to validate search results before downloading.

Best practices

  • Ensure rclone is configured and mega:/ is accessible (test with rclone ls mega:/).
  • Run inside the provided virtualenv to satisfy dependencies (requests, beautifulsoup4, lxml).
  • Use --dry-run to preview matches before consuming bandwidth or quota.
  • Prefer --format to pick PDF or EPUB according to your reader compatibility.
  • Monitor Anna's Archive membership and rate limits: fast_download may require an account.

Example use cases

  • Add a newly released textbook to your MEGA Books folder using the title and author.
  • Script nightly downloads of requested titles and automatically mirror them to MEGA.
  • Search multiple editions and pick the preferred result interactively with --pick.
  • Validate search results with --dry-run before initiating large downloads.
  • Fallback to Anna's Archive slow_download when LibGen mirrors are unavailable.

FAQ

Do I need a MEGA account or rclone setup?

Yes. Configure rclone with your MEGA credentials and verify access (rclone ls mega:/) before running the skill.

What formats are supported and how do I prefer one?

The skill prefers EPUB by default but you can force PDF with --format pdf.

Can I preview results without downloading?

Yes. Use --dry-run to perform searches and inspect matches without downloading files.

What happens if LibGen has no mirror for a book?

The script falls back to Anna's Archive fast_download or slow_download links; fast_download may require membership and slow_download is rate-limited.