spindrift aba1a68dda Backport bug fixes from NemesisHubris/litfinder (addresses #999, #956, #1010, #1021, #1025, #1040) (#1066)
## Backport bug fixes from `NemesisHubris/litfinder`

Forwards a curated set of bug fixes from
[NemesisHubris/litfinder](https://github.com/NemesisHubris/litfinder) —
a community fork of this project — that address open issues here. All
commits preserve original authorship via `git cherry-pick`; this PR is a
backport rather than original work. Each fix has been reviewed locally,
lint/format-cleaned to match this repo's existing ruff config, and
verified with the test suite. Rebrand strings, license switches, and
features have been deliberately excluded.

### Upstream issues addressed

- **#999** — Mirror URLs with query params no longer break search
requests (strip query string/fragment in `normalize_http_url`)
- **#956** — Apprise notifications now respect the configured proxy
(proxy env vars injected before dispatch)
- **#1025** — rTorrent: separate `RTORRENT_AUDIOBOOK_LABEL` setting,
falls back to book label if unset
- **#1010** — Stop button in Activity no longer makes the panel
disappear (snapshot refresh on cancel)
- **#1021** — Anna's Archive slow-download countdown now caps retries
instead of looping forever
- **#1040** — Empty destination directory cleaned up when write probe
fails
- **PR #1031** — Language detection from Anna's Archive distant path
when listing metadata is missing

### Additional fixes (no open issue but clear bugs)

- **fix: Python 2 `except` syntax across 27 files** — `except X, Y:` is
a SyntaxError in Python 3 and prevents affected modules from importing
at runtime. Mechanical sweep to `except (X, Y):`.
- **fix(abb): info hash validation with magnet fallback** — adds
SHA-1/SHA-256 hex validation on extracted info hashes; falls back to
scanning the full page for a magnet link (e.g. posted in comments) when
the table value is malformed. Also extends the exact-phrase fallback to
manual queries and defaults the ABB listing language to `en` when
missing, preventing valid results from being hidden by the language
filter. Includes a small test-fixture fix (`test(abb): use valid hex
info hashes in scraper test fixtures`) since the existing fixtures used
non-hex placeholders that the new validation correctly rejects.
- **fix: Anna's Archive title parser** — handles nested edition spans
and filters `lgli` catalog descriptor entries (e.g. "Book/Online Audio")
that were polluting search results.

### Deliberately not included

- LitFinder rebranding (UI strings, Apprise app ID, logo). The `fix:
three upstream bugs` commit (#999/#956/#1025) was cherry-picked with
Apprise app-id, description, and logo-URL strings reverted from
"LitFinder" back to "Shelfmark"; noted in the commit body.
- Features from the LitFinder fork (multi-variant title search,
multi-book flat-folder grouping, fuzzy text matching, "Leave in Place"
output handler, admin display name, custom-source plugin system). These
are larger behavior changes that each warrant their own focused review —
happy to send any of them separately if of interest.
- LitFinder-specific test environment and CI infrastructure.

### Verification

- Backend: **1879 passed**, 96 skipped (1 preexisting failure on
`seleniumbase`-dependent test in local venv; runs fine in the standard
Docker image with the `browser` extra)
- Lint, format, dead-code: all clean against this repo's existing
ruff/vulture config
- One follow-up cleanup commit (`style: ruff lint and format fixes for
ported commits`) brings the cherry-picked code into compliance with this
repo's ruff settings — no behavior changes there

### Etiquette / credit

Per-commit authorship preserved by cherry-pick. The only edits to the
original commits are:
- `fix: three upstream bugs` — Apprise rebrand strings reverted to
"Shelfmark" (noted in commit body, original author retained as
`Co-Authored-By` via cherry-pick)
- One follow-up `style:` commit for ruff config alignment

Big thanks to [@NemesisHubris](https://github.com/NemesisHubris) for the
original work in LitFinder; this PR exists to make sure these fixes
reach Shelfmark's wider user base. Happy to revise scope, split into
smaller PRs, or split off the Py2 cleanup separately if that's
preferable.

---------

Co-authored-by: NemesisHubris <155838970+NemesisHubris@users.noreply.github.com>
Co-authored-by: CaliBrain <calibrain@l4n.xyz>
2026-06-15 00:28:43 -04:00
2026-06-14 01:19:08 -04:00
2026-04-12 12:39:15 +01:00
2026-04-12 12:39:15 +01:00
2026-04-13 11:40:41 +01:00
2026-04-13 11:40:41 +01:00
2026-04-12 12:39:15 +01:00
2026-04-15 18:50:13 +01:00
2026-05-14 14:46:43 +01:00

📚 Shelfmark: Book Search & Request Tool

Shelfmark

Note

This project is in a stable state as of May 2026 but is not under active maintenance.

Shelfmark is a self-hosted web interface for searching and requesting books and audiobooks across multiple sources. Bring your own sources, metadata providers, and download clients to build a single hub for your digital library. Supports multiple users with a built-in request system, so you can share your instance with others and let them browse and request books on their own.

Works great alongside the following library tools, with support for automatic imports:

Features

  • One-Stop Interface - A clean, modern UI to search, browse, and download from multiple configured sources in one place
  • Multiple Sources - Configurable web, torrent, usenet, and IRC source support
  • Audiobook Support - Full audiobook search and download with dedicated processing
  • Flexible Search - Search metadata providers (Hardcover, Open Library, Google Books) for rich book and audiobook discovery, or query configured sources directly
  • Multi-User & Requests - Share your instance with others, let users browse and request books, and manage approvals with configurable notifications
  • Authentication - Built-in login, OIDC single sign-on, proxy auth, and Calibre-Web database support
  • Real-Time Progress - Unified download queue with live status updates across all sources
  • Network Flexibility - Configurable proxy support, DNS settings, and optional Cloudflare handling for protected sources

🖼️ Screenshots

Home screen Home screen

Search results Search results

Multi-source downloads Multi-source downloads

Download queue Download queue

🚀 Quick Start

Prerequisites

  • Docker & Docker Compose

Installation

  1. Download the docker-compose file:

    curl -O https://raw.githubusercontent.com/calibrain/shelfmark/main/compose/docker-compose.yml
    
  2. Start the service:

    docker compose up -d
    
  3. Open http://localhost:8084

Open the web interface, then configure the sources and settings you want to use.

Volume Setup

volumes:
  - /your/config/path:/config # Config, database, and artwork cache directory
  - /your/download/path:/books # Downloaded books
  - /client/path:/client/path # Optional: For Torrent/Usenet downloads, match your client directory exactly.

Tip

: Point the download volume to your CWA or Grimmory ingest folder for automatic import.

Note

: CIFS shares require nobrl mount option to avoid database lock errors.

Non-root container mode

  • Start the container as 1000:1000 with Docker user: "1000:1000" or docker run --user 1000:1000.
  • For Kubernetes, set runAsUser: 1000, runAsGroup: 1000, and runAsNonRoot: true together.
  • PUID/PGID keep the default root startup flow.
  • Mounted paths must already be writable by 1000:1000.
  • USING_TOR=true requires root startup.

⚙️ Configuration

Search Modes

Direct

  • Queries configured sources directly

Universal (recommended)

  • Search via metadata providers (Hardcover, Open Library, Google Books) for richer results
  • Aggregates releases from multiple configured sources
  • Full audiobook support

Environment Variables

Environment variables work for initial setup and Docker deployments. They serve as defaults that can be overridden in the web interface.

Variable Description Default
FLASK_PORT Web interface port 8084
INGEST_DIR Book download directory /books
TZ Container timezone UTC
PUID / PGID Runtime user/group for the default root-startup flow (also supports legacy UID/GID) 1000 / 1000
SEARCH_MODE direct or universal universal
USING_TOR Enable Tor routing (requires root startup) false

See the full Environment Variables Reference for all available options.

Some of the additional options available in Settings:

  • Prowlarr - Configure indexers and download clients to download books and audiobooks
  • Additional audiobook sources - Configure additional sources for audiobook discovery
  • IRC - Add details for IRC book sources and download directly from the UI
  • Library Link - Add a link to your Calibre-Web or Grimmory instance in the UI header
  • File processing - Customiseable download paths, file renaming and directory creation with template-based renaming
  • Network Settings - Custom proxy support (SOCKS5 + HTTP/S) and configurable DNS
  • Format & Language - Filter downloads by preferred formats, languages and sorting order
  • Metadata Providers - Configure API keys for Hardcover, Open Library, etc.

🐳 Docker Variants

Standard

docker compose up -d

The full-featured image with all network capabilities included.

Tor Routing

Optional Tor support for network privacy:

curl -O https://raw.githubusercontent.com/calibrain/shelfmark/main/compose/docker-compose.tor.yml
docker compose -f docker-compose.tor.yml up -d

Notes:

  • Requires root startup
  • Requires NET_ADMIN and NET_RAW capabilities
  • Timezone is auto-detected from Tor exit node
  • Custom DNS/proxy settings are ignored when Tor is active

Lite

A lighter image without the built-in browser automation. Ideal for:

  • External services - Already running FlareSolverr or similar for other applications
  • Alternative sources - Using Prowlarr, IRC, or other configured sources
  • Audiobooks - Using Shelfmark primarily for audiobooks
curl -O https://raw.githubusercontent.com/calibrain/shelfmark/main/compose/docker-compose.lite.yml
docker compose -f docker-compose.lite.yml up -d

If you need browser-based access with the Lite image, configure an external resolver in Settings.

🔐 Authentication

Authentication is optional but recommended for shared or exposed instances. Multiple authentication methods are available in Settings:

1. Single Username/Password

2. Proxy (Forward) Authentication

Proxy auth trusts headers set by your reverse proxy (e.g. X-Auth-User). Ensure Shelfmark is not directly exposed, and configure your proxy to strip/overwrite these headers for all inbound requests.

3. OIDC (OpenID Connect)

Integrate with your identity provider (Authelia, Authentik, Keycloak, etc.) for single sign-on. Supports PKCE flow, auto-discovery, group-based admin mapping, and auto-provisioning of new users.

4. Calibre-Web Database

If you're running Calibre-Web, you can reuse its user database by mounting it:

volumes:
  - /path/to/calibre-web/app.db:/auth/app.db:ro

Multi-User Support

With any authentication method enabled, Shelfmark supports multi-user management with admin/user roles. Users can have per-user settings for download destinations, email recipients, and notification preferences. Non-admin users only see their own downloads and can submit book requests for admin review. Admins can configure request policies per source to control whether users can download directly, must submit a request, or are blocked entirely.

Project Scope

Shelfmark is a manual search and download tool, the entry point to your book library, not a library manager. It finds books, downloads them, and sends them to a configured destination. That's the full scope.

Shelfmark intentionally does not:

  • Track or manage your library - it doesn't know or care what you already own
  • Integrate with library software - what happens after delivery is up to your library tool
  • Monitor authors, series, or new releases - there is no background automation
  • Queue future downloads - if a book isn't available now, Shelfmark won't watch for it

These are non-goals, not missing features.

Contributing

Shelfmark's core feature set is complete. Development focuses on stability, bug fixes, quality-of-life improvements, and refining the search experience. Contributions in these areas are welcome, please file issues or submit pull requests on GitHub.

Feature requests that fall outside the project scope (library integration, automation, collection management) will be closed. If you're unsure whether something fits, open a discussion first.

Health Monitoring

The application exposes a health endpoint at /api/health (no authentication required). Add a health check to your compose:

healthcheck:
  test: ["CMD", "curl", "-sf", "http://localhost:8084/api/health"]
  interval: 30s
  timeout: 30s
  retries: 3

Logging

Logs are available via:

  • docker logs <container-name>
  • /var/log/shelfmark/ inside the container (when ENABLE_LOGGING=true)

Log level is configurable via Settings or LOG_LEVEL environment variable.

Development

# Quality checks
make checks              # Run ALL static analysis (frontend + Python)
make python-checks       # Run Ruff, BasedPyright, and Vulture
make install-python-dev  # Sync Python runtime + dev tools with uv

# Frontend development
make install     # Install dependencies
make dev         # Start Vite dev server (localhost:5173)
make build       # Production build
make frontend-typecheck  # TypeScript checks

# Backend (Docker)
make up          # Start backend via docker-compose.dev.yml
make down        # Stop services
make refresh     # Rebuild and restart
make restart     # Restart container

The frontend dev server proxies to the backend on port 8084.

License

MIT License - see LICENSE for details.

⚠️ Disclaimer

Shelfmark is a search interface that displays results from external metadata providers and sources. It does not host, store, or distribute any content. The developers are not responsible for how the tool is used or what is accessed through it.

Users are solely responsible for:

  • Ensuring they have the legal right to download any material they access
  • Complying with copyright laws and intellectual property rights in their jurisdiction
  • Understanding and accepting the terms of any sources they configure

Use of this tool is entirely at your own risk.

Support

For issues or questions, please file an issue on GitHub.

Description
No description provided
Readme MIT 57 MiB
Languages
Python 73.5%
TypeScript 24.9%
Shell 0.9%
CSS 0.4%
Dockerfile 0.2%
Other 0.1%