Skip to content

feat: eReader email labels + AnythingLLM integration#3655

Open
allencai222 wants to merge 3 commits into
janeczku:masterfrom
allencai222:dev
Open

feat: eReader email labels + AnythingLLM integration#3655
allencai222 wants to merge 3 commits into
janeczku:masterfrom
allencai222:dev

Conversation

@allencai222

Copy link
Copy Markdown

Summary

This PR introduces two independent UX improvements for Calibre-Web users:

1. eReader email label support + send to specific address

Problem: Users with multiple Kindle/eReader email addresses configured (comma-separated in their profile) cannot choose which device to send a book to — it always sends to all addresses simultaneously.

Changes:

  • cps/helper.py: valid_email() now accepts Name <email> entries alongside plain addresses. A new extract_email() helper extracts the bare address from either format.
  • cps/templates/user_edit.html: Input type changed from email to text; label updated to explain the Name <email> syntax.
  • cps/web.py (send_to_ereader): Reads a email POST parameter and validates it against the current user's own address list before sending to that single address.
  • cps/templates/detail.html: Dropdown items show Format → Label (using the configured label/name, falling back to the raw address). Each item passes the bare address via data-email.
  • cps/static/js/details.js: AJAX POST now includes the selected email field.

Backward compatibility: Existing plain-address entries continue to work without changes. The fallback for missing/invalid email POST param is the first configured address.


2. AnythingLLM integration

Problem: There is no built-in way to push books from Calibre-Web into a local AI knowledge base.

Changes:

  • cps/config_sql.py: Two new config fields — config_anythingllm_url and config_anythingllm_api_key.
  • cps/admin.py: Persists the two new fields via _config_string.
  • cps/templates/config_edit.html: Admin UI — enable checkbox + server URL + API key inputs (collapsed when disabled, styled consistently with the Goodreads section).
  • cps/web.py (send_to_anythingllm): POST route that uploads the book file (EPUB or PDF) to AnythingLLM's document API, then embeds it into a per-book workspace named calibre-{title} (auto-created if absent).
  • cps/templates/detail.html: "Send to AnythingLLM" button rendered only when the integration is configured, for books that have an EPUB or PDF.
  • cps/static/js/details.js: Click handler with spinner/disabled state during the (potentially slow) embedding request.

No external dependencies: Uses Python's standard urllib.request only.

Test plan

  • Profile page: enter My Kindle <user@kindle.com>, Backup <other@kindle.com> — save succeeds, plain addresses also still accepted
  • Book detail: single email → button shows label; multiple emails → dropdown lists Format → Label per entry; clicking sends only to that address
  • Admin config: AnythingLLM section visible, saves URL + key, section hidden when unchecked
  • Book detail with AnythingLLM configured: "Send to AnythingLLM" button appears for EPUB/PDF; absent when integration disabled
  • AnythingLLM button: spinner shown during request; success/error flash message displayed

🤖 Generated with Claude Code

allencai and others added 3 commits June 4, 2026 12:10
Allow users with multiple Kindle emails to choose a specific recipient
via dropdown (format → email). Backend validates selected email against
the user's own kindle_mail list before sending.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Allows admins to configure an AnythingLLM server (URL + API key) via
the Basic Configuration page. When configured, a "Send to AnythingLLM"
button appears on book detail pages for EPUB/PDF files. Clicking it
uploads the book and embeds it into a per-book workspace named
"calibre-{title}", creating the workspace if it does not exist.

- config_sql.py: add config_anythingllm_url / config_anythingllm_api_key
- admin.py: persist the two new config fields
- config_edit.html: admin UI with enable checkbox + URL + API key inputs
- web.py: POST /send-to-anythingllm/<book_id>/<format> route
- detail.html: conditional button shown only when integration is enabled
- details.js: click handler with loading state and error feedback

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Users can now enter entries as 'My Kindle <user@kindle.com>' in their
profile alongside plain addresses. The book detail dropdown shows the
label instead of the raw address, and each click sends to only that
one device. extract_email() is added to helper.py to parse both formats.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant