6 Commits

Author SHA1 Message Date
9cb9b8c7fd Lazy config, cross-platform support, session recovery, doc accuracy
Code:
- Defer boto3 client and DATABASE_URL reads to first use via
  _ensure_config(). Missing .env now prints a friendly "Missing env
  vars" list and exits instead of KeyError on import.
- Auto-detect Chrome binary from CHROME_CANDIDATES (macOS/Linux/Windows
  paths). Friendly error listing tried paths if none found.
- Guard termios/tty imports; EscListener becomes a no-op on Windows.
- hide_chrome() is a no-op on non-macOS (osascript only works on Darwin).
- with_browser catches target-closed/disconnected errors, resets the
  session singleton, and retries once before raising.

Docs:
- Fix claim that page.goto is never used — manga listing uses
  page.goto, only reader pages use window.location.href.
- Correct AppleScript command (full tell-application form).
- Clarify "Check missing pages" flow — re-upload is inline; dim-only
  fix reads bytes from R2 without re-upload.
- Add CREATE TABLE statements for Manga/Chapter/Page so schema contract
  is explicit.
- Add "Where to change what" table mapping tasks to code locations.
- Document lazy config, cross-platform constraints, and anti-patterns
  (headless, thread parallelism).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 18:32:20 +08:00
051b2e191f Re-upload inline during check, add URL fallback for flaky CDN
- Check missing pages: re-upload happens immediately when mismatch is
  detected, while the browser is still on that chapter's reader page.
  Eliminates the two-phase approach that required re-navigating and
  could hit wrong referrer.
- fetch_image_bytes falls back to stripped-query URL (e.g. drops ?q=50)
  when the original fails — works around CDN variants that may not
  have the quality-scaled version.
- Log the specific failing URL on fetch failure for diagnostics.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 13:12:55 +08:00
723b82c9fc Add chapter-level DB tools, dim sync, retries, and all-genres
- Check missing pages: compare site page count vs R2, detect NULL/0
  width/height in DB and fix by reading WebP bytes from R2 (no re-upload
  needed when dims are just missing).
- Delete specific chapter(s): multi-select or all, removes from R2+DB.
- Chapter pickers now offer "All chapters" as first option.
- Save all genres comma-separated in Manga.genre (was only the first).
- Sync refreshes title/description/genre for existing manga records.
- Page inserts now save width and height from PIL (schema update).
- Retry failed page fetches up to 3 attempts with 2s backoff instead
  of skipping after one failure.
- Cover detection polls DOM up to 8s and tries broader selectors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 12:59:22 +08:00
e037996c5c Add ESC-to-stop, manga edit, R2 recompress, persistent browser session
- Persistent Chrome session: lazy-started, reused across all operations
  in one run (closed only on Quit). Eliminates per-command startup delay.
- ESC key gracefully stops Download/Upload/Sync after current chapter.
- Edit manga info: TUI form to update title/description/genre/status/cover
  in DB without re-syncing.
- R2 recompress: re-encode all webp images for a manga at quality 65 to
  reclaim storage. Skips files where new size is not smaller.
- Sync now refreshes title/description/genre on existing manga records,
  and saves all genres comma-separated (was only the first).
- Cover detection waits up to 8s for image to appear in DOM, with
  fallback selector.
- WebP encoding uses method=6 quality=75 for smaller files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 10:17:06 +08:00
fab3b413b8 Merge download.py and upload.py into unified manga.py with TUI
- Single interactive script (arrow-key TUI via simple-term-menu) replaces
  download.py, upload.py, and export_cookies.py
- Add sync command: streams new chapters site -> R2 directly without
  saving locally (uses RAM as cache)
- Add R2/DB management submenu (status, delete specific, clear all)
- Multi-select chapter picker with already-downloaded marked grayed out
- Chapter list fetched via /v2.0/apis/manga/chapterByPage with pagination
- Cover image captured from page network traffic (no extra fetch)
- Filter prefetched next-chapter images via DOM container count
- Chrome runs hidden via AppleScript on macOS (except setup mode)
- DB records only created after R2 upload succeeds (no orphan rows)
- Parallel R2 uploads (8 workers) with WebP method=6 quality=75
- Update CLAUDE.md to reflect new architecture
- Add requirements.txt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 08:56:05 +08:00
721ad213ee first commit 2026-04-11 16:55:13 +08:00