Browser Session State as a Book Acquisition API

repotoolcliautomationagent-toolsbooksnaspdf-brain

Turns browser-authenticated book acquisition into a repeatable CLI step for Joel's PDF/library pipeline.

aa-download is a tiny aa-book CLI for getting books out of Anna’s Archive and into the place the system can actually use them. Search by title and format, download by MD5, optionally convert epub or mobi with Calibre, then copy the result to the three-body NAS path for the year.

The clever bit is that it doesn’t pretend the world is clean. Anna’s Archive fast links need auth, so the tool uses agent-browser and browser session state instead of fighting the site like a brittle scraper. The session lives at ~/.config/annas-archive/aa-session.json, the secret comes from secrets, and the daily counter keeps the quota visible instead of hiding it in vibes.

That’s useful because book acquisition is usually a shitty edge-case swamp: browser-only login, format mismatches, local staging directories, quota limits, and final storage all glued together by memory. This makes it a command with status, logs, and a predictable handoff into the pdf-brain incoming path.

Key Ideas

  • aa-book wraps Anna’s Archive search and download into a scriptable CLI instead of a manual browser chore.
  • Browser-authenticated fast links use agent-browser session state at ~/.config/annas-archive/aa-session.json.
  • Optional Calibre conversion turns epub and mobi files into PDFs when the downstream pipeline wants PDF-shaped inputs.
  • The tool has explicit operational breadcrumbs: daily quota file, /tmp/aa-book-progress.log, aa-book status, and NAS transfer to joel@three-body:/volume1/home/joel/books/YYYY/.
  • The custom download directory flow maps directly to the pdf-brain staging path shown in the README: /Users/joel/clawd/data/pdf-brain/incoming.