Commit Graph

291 Commits

Author SHA1 Message Date
kikootwo ac2ad8aac2 Add BookDate card stack animations and thumbnail caching
Implements pure CSS card stack animations for BookDate recommendations, including smooth exit and advance transitions. Adds local caching of library cover thumbnails during scans, updates database schema and API to serve cached covers, and enhances BookDate to support 'favorites' scope with a book picker modal. Updates admin settings validation logic for Prowlarr, improves indexer state management, and documents new features and backend changes.
2026-01-28 11:41:59 -05:00
kikootwo 2d9ed5c76a Add retry logic with exponential backoff to AudibleService
Introduces a fetchWithRetry method to handle network errors and rate limiting (503, 429) with exponential backoff in AudibleService. Updates getPopularAudiobooks and getNewReleases to use this retry logic and improves error handling to stop pagination on errors but return collected results. Test cases are updated to use non-retryable errors (404) for more accurate coverage.
2026-01-28 11:41:59 -05:00
kikootwo dac9183797 Replace setImmediate with queueMicrotask in tests
Updated ebook-scraper tests to use queueMicrotask instead of setImmediate for emitting 'finish' events. This change ensures microtasks run before timers, reducing race conditions with download timeouts.
2026-01-28 11:41:59 -05:00
kikootwo 3a9ae4a439 Add request approval system and audiobook path template
Implements admin approval workflow for user requests with global and per-user auto-approve controls. Adds new request statuses ('awaiting_approval', 'denied'), related API endpoints, and UI for pending approvals. Introduces configurable audiobook organization path template with validation and preview in settings, updates database schema and migrations for new fields.
2026-01-28 11:41:59 -05:00
kikootwo 428d9a12e0 Improve test output parsing in CI workflow
Strips ANSI color codes from test output for reliable parsing and updates grep logic to use the last relevant lines for test files, tests, and duration. This enhances robustness when extracting test statistics from vitest output in the GitHub Actions workflow.
2026-01-28 11:41:59 -05:00
kikootwo d07b10e407 Improve test output parsing and add debug info
Enhanced the parsing logic in the test workflow to use 'head -1' for more robust extraction of test summary lines and values. Added debug output to display relevant lines and parsed values for easier troubleshooting.
2026-01-28 11:41:59 -05:00
kikootwo d67915b7bc Parse test results from vitest default reporter
Update the workflow to extract test statistics from vitest's default reporter output in test-output.txt, replacing the previous JSON reporter parsing. This ensures test metrics are still collected and reported even when the JSON reporter is not used.
2026-01-28 11:41:59 -05:00
kikootwo 94dbaf073b Add backend unit test framework and modularize settings UI
Introduced a Vitest-based backend unit testing framework with supporting scripts, helpers, and GitHub Actions integration. Refactored the admin settings page to a modular architecture, splitting monolithic logic into feature-specific tabs and hooks for improved maintainability and testability. Updated documentation to reflect the new testing setup and settings architecture, and added new dependencies for testing utilities.
2026-01-28 11:41:59 -05:00
kikootwo b3f89d67bb Update Audiobookshelf API key instructions and improve chapter merging
Replaces outdated Audiobookshelf API token instructions with new API key generation steps across documentation and UI. Enhances chapter merging logic to detect and handle book titles in metadata, prioritizing filename extraction for chapter names, and updates logging and documentation to reflect these changes. Adds ASIN copy-to-clipboard feature in AudiobookDetailsModal.
2026-01-28 11:41:59 -05:00
kikootwo 307b63fab4 Refactor indexer management and improve search logic
Refactors admin settings to use a new IndexersTab and card-based indexer management UI, supporting category selection and improved configuration. Updates backend and API routes to handle indexer categories, propagate ASIN for better search scoring, and group indexers by categories to optimize Prowlarr searches. Enhances documentation to clarify non-terminal request matching and auto-completion behavior. Adds new reusable components for indexer management and category selection.
2026-01-28 11:41:59 -05:00
kikootwo e346f88f42 Add Audible region config and user password change modal
Implements configurable Audible region selection in setup and admin settings, affecting all Audible API calls and triggering data refresh on change. Adds a user-facing 'Change Password' modal in the header for local users, moving password change from admin-only to all local users via a new /api/auth/change-password endpoint. Updates documentation, API routes, and context to support these features, and removes the old admin-only password change flow.
2026-01-28 11:41:58 -05:00
kikootwo 50fb5a68af Add custom AI provider support and improve qBittorrent auth
Introduces support for custom OpenAI-compatible AI providers with configurable base URLs, including UI, backend validation, and connection testing. Enhances qBittorrent integration to support HTTP Basic Auth for reverse proxies, adds detailed debug logging, and updates documentation for both features. Also improves login page description logic and AI prompt generation for recommendations.
2026-01-28 11:41:58 -05:00
kikootwo 682836237b Implement centralized logging with RMABLogger
Replaces scattered console statements with a unified RMABLogger across backend API routes and services. Adds LOG_LEVEL-based filtering, job-aware database persistence, and context-based logging. Updates documentation to describe the new logging system and usage patterns. Also documents qBittorrent CSRF header fix
2026-01-28 11:41:58 -05:00
kikootwo ba5f5cf7d6 Move ARG declarations after FROM in Dockerfile
Re-declared build arguments GIT_COMMIT and BUILD_DATE after the FROM instruction to ensure they are available in subsequent build stages, as ARGs before FROM are not accessible after the base image is set.
2026-01-28 11:41:58 -05:00
kikootwo 384601014a Add filesystem scan trigger and version badge features
Implements optional filesystem scan triggering for Plex and Audiobookshelf after file organization, with new settings in the admin UI, setup wizard, and API. Updates documentation to reflect scan trigger options and improved file organization/cleanup logic. Refactors dropdown menus to use smart positioning and portals for better UX. Adds a version API route and a VersionBadge component to display build info in the header. Updates Docker build to inject version metadata.
2026-01-28 11:41:58 -05:00
kikootwo 288421012d Implement chapter merging feature and update ranking algorithm
Added automatic chapter merging to M4B with admin/config toggles, UI controls, and backend logic. Updated documentation to reflect implementation. Refactored ranking algorithm: increased Title/Author match points, removed size scoring, and improved Usenet/torrent handling. Enhanced Prowlarr integration for protocol detection and filtering. Improved file organizer to support chapter merging. Various bug fixes and logging improvements.
2026-01-28 11:41:58 -05:00
kikootwo 722a78ac33 Add e-book fetch API and UI integration for requests
Introduces an API endpoint to trigger e-book downloads for completed requests, with admin UI integration in RecentRequestsTable and RequestActionsDropdown. Updates the admin dashboard to detect e-book sidecar feature availability from settings. Enhances torrent search result handling with info URLs, improves ranking algorithm normalization, and refines interactive search to show all results without threshold filtering. Also allows nullable ratings in request schemas.
2026-01-28 11:41:58 -05:00
kikootwo 95c25ff73a Add e-book sidecar integration and improve request handling
Introduces optional e-book sidecar downloads from Anna's Archive, including admin UI, settings API, FlareSolverr integration, and documentation. Enhances request creation logic to prevent duplicate downloads by checking for 'downloaded' and 'available' statuses, updates UI to reflect processing state, and adds SABnzbd support to download and cleanup flows. Also updates ranking algorithm documentation and improves cache invalidation for recent requests.
2026-01-28 11:41:58 -05:00
kikootwo 24ea53bd2f Improve SABnzbd API key handling and settings UI
Clear credentials when switching download client types in the admin settings page and update validation logic for enabling the test connection button. In SABnzbd service, trim API key input and add explicit validation and error handling for missing or invalid API keys during connection tests.
2026-01-28 11:41:58 -05:00
kikootwo e008744df1 Add SABnzbd Usenet/NZB integration and documentation
Introduces SABnzbd as a supported download client for Usenet/NZB alongside qBittorrent, including service implementation, setup wizard and admin settings UI updates, and protocol-specific job processor logic. Updates documentation, PRD, and database schema to support NZB downloads, adds comprehensive technical details and testing strategies, and fixes Audible integration issues related to search and ASIN extraction.
2026-01-28 11:41:58 -05:00
kikootwo 23881eb670 Add indexer flag bonuses and SSL verify toggle
Implements configurable indexer flag bonuses/penalties for torrent ranking, including UI for admin settings and support in ranking-algorithm. Adds an option to disable SSL certificate verification for qBittorrent connections (for self-signed certs), with UI in both setup and admin settings, and persists the setting. Updates documentation, API routes, and ranking logic to support these features. Also includes minor UI improvements and bug fixes.
2026-01-28 11:41:58 -05:00
kikootwo ca7cac0c88 Add remote path mapping for qBittorrent integration
Implements remote-to-local path mapping for qBittorrent downloads, allowing the app to handle differing filesystem paths between qBittorrent and the local environment (e.g., remote seedboxes, Docker). Adds UI controls in admin settings and setup wizard, validates mapping configuration, and applies path transformation in download and import processors. Updates documentation, API routes, and data models to support the new feature. Also improves library scan logic to remove stale records and reset orphaned audiobooks and requests. Increases minimum torrent score threshold from 30 to 50 in search and ranking logic, and exposes torrent source URLs in the admin UI.
2026-01-28 11:41:57 -05:00
kikootwo d617e26c92 Add ASIN support to file organization and metadata
This update enhances audiobook file organization by including the ASIN in folder names and embedding it as a custom metadata tag in audio files (M4B/M4A/MP3). Documentation is updated to reflect the new folder naming convention and metadata tagging. Additionally, local login and registration can now be disabled via an environment variable, and the interactive torrent search modal allows custom search titles for all modes.
2026-01-28 11:41:57 -05:00
kikootwo 1374e66f13 Improve torrent search and ranking algorithm
Enhanced the ranking algorithm to better distinguish complete title matches from partial matches, reducing series confusion. Updated the torrent search modal to allow users to customize the search title for new requests, improving search flexibility. Also refined request lookup to ignore deleted requests.
2026-01-28 11:41:57 -05:00
kikootwo f043688a71 Implement user soft-delete and improve search ranking
Adds soft-delete support for local users, including backend, API, and UI changes to allow admins to delete local users while preserving their requests. Updates user queries to exclude deleted users and allows username reuse for deleted accounts. Refines search and ranking logic for torrents: uses title-only queries for broader results, increases max results to 100, applies a minimum score threshold (30/100), and logs detailed ranking breakdowns. Updates the ranking algorithm to prioritize title/author match, adjusts scoring weights, and improves BookDate compatibility with Audiobookshelf by disabling rating-based features when unsupported. Enhances file copy operations for large files, improves metadata tagging, and updates documentation to reflect new search and ranking strategies.
2026-01-28 11:41:57 -05:00
kikootwo bb42281dac Improve user auth handling and download monitoring
Adds detection of local users for authentication validation and login, prevents role changes for OIDC users, and clarifies user management UI. Enhances active downloads API to include speed and ETA from qBittorrent, and improves file path handling in download monitoring. Also updates torrent tagging and user info returned by APIs.
2026-01-28 11:41:57 -05:00
kikootwo 174e9f05b6 Add admin request deletion with soft delete and cleanup
Implements admin ability to delete requests with soft delete, media file cleanup, and seeding-aware torrent management. Adds new API endpoint, frontend confirmation dialog, and request actions dropdown. Updates database schema with deletedAt and deletedBy fields, and ensures all queries filter out deleted requests. Documentation added for feature and user flow.
2026-01-28 11:41:57 -05:00
kikootwo bba4af7398 Fix indexerIds serialization in ProwlarrService
Update axios paramsSerializer and request logic to send indexerIds as repeated query parameters (indexerIds=1&indexerIds=2) instead of a comma-separated string. This ensures compatibility with Prowlarr's expected API format.
2026-01-28 11:41:57 -05:00
kikootwo 1cefa437b7 Add ASIN/ISBN fields to library and improve matching
Introduces `asin` and `isbn` fields to the PlexLibrary schema and database, with migration and indexing for fast lookups. Updates scan and recently-added processors to persist ASIN/ISBN from both Plex and Audiobookshelf backends. Enhances matching logic to prioritize exact ASIN matches using the new fields, improving match accuracy for Audiobookshelf users. Also includes minor improvements: fixes cover art handling for cached thumbnails, adds download URL validation in Prowlarr and qBittorrent integrations, and updates documentation to reflect these changes.
2026-01-28 11:41:57 -05:00
Claude a3381cba31 Fix qBittorrent service not reloading config after settings change
Root cause: Singleton caching issue
The qBittorrent service uses a singleton pattern with a configLoaded flag.
Once initialized, it NEVER re-reads the database config, even when the
user changes settings via the admin settings page.

Flow showing the bug:
1. Wizard saves download_dir to database ✓
2. First torrent: service reads config, creates singleton, sets configLoaded=true ✓
3. User changes download_dir in settings page ✓ (database updated)
4. Next torrent: getQBittorrentService() returns CACHED singleton ✗
5. Cached singleton has OLD download_dir value in this.defaultSavePath ✗
6. Category check shows "already has correct save path: /old/path" ✗
7. Download goes to wrong location ✗

The singleton check (line 745):
  if (!qbittorrentService || !configLoaded) {
    // Only runs if service doesn't exist or config failed
  }
Once both exist, this block is SKIPPED forever!

Fix:
1. Added invalidateQBittorrentService() function
   - Resets qbittorrentService = null
   - Resets configLoaded = false
   - Forces reload from database on next use

2. Call invalidation from settings APIs:
   - After updating paths (download_dir, media_dir)
   - After updating download client (URL, credentials)

3. Next torrent addition:
   - getQBittorrentService() sees null singleton
   - Re-reads config from database
   - Creates new service with current download_dir
   - Category updated with correct path

Benefits:
- Settings changes take effect immediately
- No app restart needed
- Category save path always matches current config
- Download client credentials always current

Updated documentation to explain singleton invalidation pattern.
2026-01-28 11:41:57 -05:00
Claude 0222bca9f7 Fix category save path not updating - check before create/edit
Root cause: We were blindly calling createCategory (409 if exists) then
editCategory (409 for unknown reason), but editCategory was failing and
the category kept its old save path, causing downloads to wrong location.

The 409 from editCategory doesn't mean 'already has this path', it means
the operation failed. Without checking first, we don't know why.

New approach:
1. GET /torrents/categories first to check current state
2. If category doesn't exist: create it with correct save path
3. If category exists with wrong path: edit to update save path
4. If category exists with correct path: skip (no API call needed)

Benefits:
- Avoids unnecessary 409 errors
- Only calls editCategory when actually needed
- Logs show exactly what's happening (create/update/skip)
- Handles both savePath and save_path response formats (v4.4.0+ compat)
- Better error logging with full response details

This ensures category save path is ACTUALLY updated when user changes
download_dir setting, fixing downloads going to wrong location.

References:
- qBittorrent API docs: https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)
- Issue #15969: save_path vs savePath inconsistency in API v2.8.4+
2026-01-28 11:41:57 -05:00
Claude 0fa10941e1 Handle 409 from editCategory as non-error
qBittorrent's /torrents/editCategory endpoint returns 409 (Conflict) when
the category already has the specified save path (no change needed).

This is expected behavior when:
- User hasn't changed download_dir setting since last torrent
- Category already has correct save path

Previously logged as warning with full error stack trace, making it look
like an error when it's actually normal operation.

Changes:
- Check for 409 status code from editCategory
- Log friendly message: 'Category already has save path: /path'
- Only log unexpected errors with console.warn

Now both createCategory and editCategory handle 409 gracefully:
- createCategory 409 = category exists
- editCategory 409 = category already has this path
Both are expected, not errors.
2026-01-28 11:41:57 -05:00
Claude 74010a1ebd Improve logging for qBittorrent category creation
The 409 (Conflict) status code from qBittorrent's createCategory endpoint
means 'category already exists', which is expected behavior, not an error.

Previously, the full error object was logged with console.log(), making it
look like an error in the logs when it's actually normal operation.

Changes:
- Check for 409 status code specifically
- Log friendly message: 'Category already exists' for 409
- Only log unexpected errors with console.warn
- Cleaner logs that don't alarm users

The flow still works correctly:
1. Try createCategory (succeeds if new, 409 if exists)
2. Always editCategory to update save path to match current config
3. Both operations complete successfully
2026-01-28 11:41:56 -05:00
Claude 5188fe1727 Fix qBittorrent category save path not updating when config changes
Previously, when a user changed the download_dir setting after initial
setup, the qBittorrent category "readmeabook" would retain the old save
path. This could cause torrents to download to the wrong location,
depending on qBittorrent's Automatic Torrent Management (ATM) settings.

Root cause:
- ensureCategory() only created the category if it didn't exist
- createCategory API is idempotent but doesn't update existing categories
- If download_dir changed from /downloads to /downloads/RMAB, category
  would still have savePath=/downloads

qBittorrent behavior:
- If ATM enabled: category savePath overrides per-torrent savepath
- If ATM disabled: per-torrent savepath takes precedence

Fix:
- ensureCategory() now calls both createCategory AND editCategory
- createCategory: ensures category exists (idempotent)
- editCategory: updates save path to match current download_dir config
- This guarantees category path is always synced with database config

Benefits:
- Users can change download_dir setting and it takes effect immediately
- Works regardless of ATM settings in qBittorrent
- No manual qBittorrent category management needed

Updated documentation/phase3/qbittorrent.md to explain category
management and save path synchronization.
2026-01-28 11:41:56 -05:00
Claude ef98dcf438 Fix file copy location to respect configured media directory
Previously, files were always being copied to /media/audiobooks regardless
of the configured media directory in settings. This was caused by:

1. FileOrganizer singleton reading from MEDIA_DIR env var (never set)
   instead of database config 'media_dir'
2. Hardcoded /media/audiobooks fallback being used when env var not found
3. Three locations passing hardcoded paths to addOrganizeJob (unused)

Changes:
- Modified getFileOrganizer() to read media_dir from database config
- Made targetPath parameter optional in addOrganizeJob (not used by processor)
- Removed hardcoded /media/audiobooks paths from all addOrganizeJob calls
- Updated organize-files processor to await getFileOrganizer()
- Updated documentation to reflect configuration behavior

Files now correctly copy to the directory configured in setup wizard or
settings page, with /media/audiobooks only as fallback if not configured.

Fixes: User-reported issue where configured media directory was ignored
2026-01-28 11:41:56 -05:00
Claude a59bbedd00 Fix critical bug: searches now respect enabled indexers
**Problem:** Prowlarr searches were querying ALL indexers instead of only
the ones enabled in user settings, causing torrents to be selected from
disabled/untrusted indexers.

**Root Cause:** The prowlarr.search() method didn't filter by indexer IDs,
and callers weren't passing enabled indexer IDs to the search.

**Changes:**
1. Added indexerIds parameter to SearchFilters interface
2. Updated prowlarr.service.ts search() to filter by indexerIds
3. Updated search-indexers.processor.ts to fetch and pass enabled indexer IDs
4. Updated interactive-search route to fetch and pass enabled indexer IDs
5. Added validation: search fails if no indexers are configured/enabled
6. Updated documentation to reflect indexer filtering behavior

**Impact:**
- Manual search: Only searches enabled indexers
- Interactive search: Only searches enabled indexers
- RSS monitoring: Already correctly filtered (no changes needed)

**Testing:** TypeScript type checking passed with no errors
2026-01-28 11:41:56 -05:00
kikootwo 477a30c2eb Update .gitignore and mask 'secret' in settings API
Added /cache, /redis, and /pgdata to .gitignore to prevent committing local data directories. Updated the admin settings API to also mask values for keys containing 'secret' in addition to other sensitive keys.
2026-01-28 11:41:56 -05:00
Claude 7c63de8fb1 Fix OIDC admin approval chicken-and-egg problem
Allow first user to bypass admin approval requirement when using
'admin_approval' access control method. The first user is auto-approved
and becomes admin, avoiding the situation where there's no admin to
approve the first user.

**Before:** First user gets stuck in pending_approval state
**After:** First user bypasses approval and becomes admin automatically

Subsequent users still require admin approval as expected.
2026-01-28 11:41:56 -05:00
Claude 7107700834 Display OIDC access denied errors on login page
Extract error messages from URL query parameters and display them
in the existing error box on the login page, then clean up the URL.

This fixes the UX issue where OIDC access denied errors were only
visible in the URL bar as query parameters.
2026-01-28 11:41:56 -05:00
Claude 5a9b6b4b46 Add comprehensive OIDC access control and admin role mapping
Implements full OIDC configuration UI and backend support for access control and admin permissions.

**Access Control Features:**
- Open access (anyone can log in)
- Group/claim based access (require specific group membership)
- Allowed list (whitelist specific emails/usernames)
- Admin approval (manual approval required for new users)

**Admin Role Mapping:**
- Automatic admin role assignment based on OIDC claims
- Configurable claim name and value (default: groups claim)
- First user always becomes admin
- Dynamic role updates on each login

**Setup Wizard:**
- Updated OIDCConfigStep with comprehensive OIDC settings
- Access control method selector with conditional fields
- Admin role mapping configuration with examples
- Improved UX with clear sections and helpful descriptions

**Admin Settings:**
- Expanded OIDC section with all new configuration options
- Proper JSON array handling for allowed emails/usernames
- Visual organization matching setup wizard

**Backend:**
- Updated setup complete API to persist new OIDC fields
- Updated OIDC settings API for all new configuration
- Updated settings GET endpoint to return new fields with defaults
- Proper comma-separated to JSON array conversion

**Documentation:**
- Comprehensive OIDC section in auth.md
- Configuration examples and use cases
- Clear distinction between access control and admin roles
- Default values documented

All changes tested and ready for production use.
2026-01-28 11:41:56 -05:00
kikootwo a3ba192fbd Initial commit 2026-01-28 11:41:24 -05:00