Commit Graph
177 Commits
Author SHA1 Message Date
crocodilestick 7d3f411da4 feat: implement global enablement for metadata providers with UI controls 2025-09-12 23:14:18 +02:00
crocodilestick ebd68c3091 Added metadata_providers_enabled to schema to resolve conflict with PR #632 2025-09-12 23:07:10 +02:00
crocodilestick 6864f338b9 feat: enhance converter robustness with timeout, validation, and error handling
- Add 300s timeout to calibredb calls to prevent hanging on large libraries
- Improve JSON parsing with validation for empty/malformed data
- Add case-insensitive format matching for mixed-case extensions
- Validate file existence before adding to conversion queue
- Enhanced convert_ignored_formats handling with robust type checking
- Add comprehensive verbose logging for better debugging
- Protect against malformed file paths and unicode issues
- Graceful handling of edge cases (empty configs, missing attributes)
2025-09-12 22:31:00 +02:00
CrocodileStick 6233bb9cf3 Merge pull request #615 from decoyjoe:bugfix/convert-library-idempotency
Fixed converter repeatedly re-converting the same books
2025-09-12 22:13:04 +02:00
crocodilestick 42e7aabe5f feat: Add retained formats functionality for auto-conversion
Implements ability to keep original book formats after conversion to target format.
Users can now select which formats to retain via CWA settings UI.

Features:
- New auto_convert_retained_formats setting with checkbox grid UI
- Automatic conflict prevention (target format always retained)
- Database migration support for backward compatibility
- Enhanced ingest processor with robust format addition logic

Credit to @angelicadvocate for original implementation concept in PR #284.

Fixes edge cases including race conditions, UI state handling, and iteration safety.
2025-09-12 21:34:32 +02:00
crocodilestick d2c018ea5d Fix ingest service failure when Google Drive sync is disabled (#621)
- Add null/empty path checks in gdriveutils.py to prevent TypeError on import
- Enhance exception handling in ingest_processor.py to catch TypeError/AttributeError
- Add session guards to all database functions for graceful degradation
- Ensure ingest service continues working when Google Drive is disabled

[bug] Book not ingested on dev image (main branch)
Fixes #621
2025-09-12 16:50:59 +02:00
crocodilestick 7c58906e53 feat: Implement configurable duplicate detection system (#604)
Fix issue where books in different languages were incorrectly grouped as duplicates
by implementing a comprehensive configurable duplicate detection system.

Key Changes:

Database Schema:
- Add 6 new duplicate detection settings to cwa_schema.sql:
  - duplicate_detection_title/author/language (default: enabled)
  - duplicate_detection_series/publisher/format (default: disabled)

Frontend UI:
- Add "CWA Duplicate Detection Criteria" section to cwa_settings.html
- Implement checkbox grid for configuring detection criteria
- Include explanatory text and validation warnings

Core Logic Rewrite:
- Replace hardcoded (title, author) matching with configurable criteria
- Support dynamic key generation based on selected metadata fields
- Add comprehensive error handling and edge case coverage

Robustness Improvements:
- Handle missing/null metadata gracefully with fallback values
- Add safety checks for empty collections and corrupt data
- Include CWA database connection error handling
- Performance warnings for large libraries (50k+ books)

Issue Resolution:
- Books in different languages no longer considered duplicates (language included by default)
- Users can now fully customize duplicate detection criteria
- Maintains backward compatibility with existing duplicate manager
- Comprehensive error handling prevents crashes on edge cases

Technical Details:
- Follows established CWA settings patterns for seamless integration
- Boolean settings automatically handled by existing backend logic
- Added datetime import for timestamp sorting fallbacks
- Extensive null/empty validation throughout duplicate detection pipeline
2025-09-12 16:26:22 +02:00
crocodilestick 0405e0937a Renamed universal-calibre-setup service to calibre-binaries-setup 2025-09-12 15:04:51 +02:00
Joseph Larionov ec7477b60f Fixed converter repeatedly re-converting the same books
Fixes #614

The converter now reliably detects if a book already exists in a target
format by getting the list of existing book format filenames directly
from the Calibre database rather than making an assumption on the
format filename.
2025-09-09 16:41:32 -07:00
crocodilestick 8402e3225e Added the ability to select which fields can be overwritten by the automatic metadata fetching service, for both the smart and verbatim modes 2025-09-05 15:46:42 +02:00
crocodilestick 3e3d2e5e4d feat: Implement auto-send and enhanced auto-metadata fetch systems
## Major Features Added

### 📧 Auto-Send System
- Automatically emails newly ingested books to users' eReaders
- Configurable delay (1-60 minutes) to allow for processing
- Supports multiple formats (EPUB, MOBI, AZW3, KEPUB, PDF)
- Integrates with existing Calibre-Web email configuration
- Respects user preferences and access controls

### 🏷️ Auto-Metadata Fetch System Enhancements
- Enhanced metadata fetching with multiple provider support
- Added smart metadata application mode with intelligent criteria
- Moved control from user-level to admin-only configuration
- Implemented provider hierarchy with drag-and-drop interface
- Added quality-based metadata replacement logic

## Database Schema Changes

### CWA Settings (scripts/cwa_schema.sql)
- Added auto_metadata_smart_application SMALLINT DEFAULT 0
- Enables intelligent vs direct metadata replacement modes

## User Interface Updates

### Admin Interface (cps/templates/cwa_settings.html)
- Added smart metadata application toggle with detailed tooltip
- Enhanced provider hierarchy management

### User Interface (cps/templates/user_edit.html)
- Removed auto_metadata_fetch controls (now admin-only)
- Cleaned up user profile interface

## Smart Metadata Application Logic

### Direct Replacement Mode (Default)
- Takes metadata from preferred provider exactly as provided
- Complete replacement of existing metadata
- Philosophy: "Just take the metadata as is"

### Smart Application Mode (Optional)
- Intelligent criteria for metadata replacement:
  * Titles: Only replace if longer/more descriptive
  * Descriptions: Only replace if longer/more detailed
  * Publishers: Only replace if current field is empty
  * Covers: Only replace if higher resolution
  * Authors: Always update for consistency
  * Tags/Series: Always add for discoverability

## Technical Implementation

### Metadata Helper (cps/metadata_helper.py)
- Enhanced _apply_metadata_to_book() with smart application logic
- Updated fetch_and_apply_metadata() for admin-only control
- Integrated CWA_DB settings checking for both modes

### Ingest Processor (scripts/ingest_processor.py)
- Removed user-based metadata checking
- Streamlined to use admin settings only
- Improved processing pipeline integration

### Form Processing (cps/cwa_functions.py)
- Auto-detection of boolean settings from schema
- Automatic handling of auto_metadata_smart_application

## Provider System Enhancements
- Google Books, Internet Archive, DNB, ComicVine, Douban support
- Priority-based searching with first-success-wins logic
- Quality criteria evaluation for metadata selection
- Configurable provider hierarchy with drag-and-drop interface

## Documentation

### Wiki Pages Created
- Auto-Send-System.md: Comprehensive user and admin guide
- Auto-Metadata-Fetch-System.md: Detailed configuration and usage
- Enhanced with relevant emojis for improved readability
- Covers troubleshooting, best practices, and technical details

## Integration & Compatibility
- Maintains backward compatibility with existing email settings
- Integrates seamlessly with auto-convert and ingest systems
- Respects existing access controls and user permissions
- No breaking changes to existing functionality

## Testing Notes
- Database schema updates will apply automatically on app startup
- Settings form processing handles new boolean field automatically
- Metadata fetching now controlled entirely by admin settings
- User interface cleaned of deprecated metadata controls

This implementation provides a complete automated book delivery and metadata enhancement system while maintaining the principle of admin-controlled automation and user-friendly operation.
2025-09-04 18:22:54 +02:00
CrocodileStick f4ba2c05f4 Merge pull request #589 from brunofin/ignore-temp-ingest
Add 'temp' to ignored formats list
2025-09-02 17:14:51 +02:00
crocodilestick 7124a955e5 Updated translation system to automatically detect and correct duplicate entries 2025-09-02 17:06:06 +02:00
crocodilestick 955320d648 Added ability to change ingest timeout duration in CWA Settings 2025-09-02 15:37:38 +02:00
crocodilestick d40eafd744 Added Arabic to generate_translation_status.py 2025-09-02 15:33:47 +02:00
Bruno Finger 0f03b4e2eb Add 'temp' to ignored formats list 2025-08-30 15:56:27 +02:00
crocodilestick 692ca19295 [bug] Error on refresh library: TypeError: NewBookProcessor.convert_book() got multiple values for argument 'end_format'
Fixes #560
2025-08-25 15:52:26 +02:00
crocodilestick 5850d6e801 [bug] E999 on sending to Kindle
Fixes #382
2025-08-25 15:51:21 +02:00
CrocodileStick 8c5fa2415a Merge pull request #518 from natabat/ingest_on_upload
Ingest on upload
2025-08-25 15:21:15 +02:00
crocodilestick 21d9dec134 Fixed ingest on upload functionality 2025-08-25 15:02:14 +02:00
Emmanuel Ferdman bf6a8996c3 Fix indentation in convert_library.py
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2025-08-24 11:04:57 -07:00
crocodilestick dbd04c1e64 Merge remote-tracking branch 'natabat/ingest_on_upload' into ingest_on_upload-review 2025-08-22 17:38:49 +02:00
crocodilestick ed1fb48c91 Changes to the uploads to ingest pipeline:
- Instead of writing directly into the library, uploads are saved safely into the ingest folder and a background worker imports them (prevents import of incomplete files)
   - Files are first saved with a temporary suffix and then atomically renamed to avoid partial/corrupt reads.

To prevent dupes & handle uploading a new format to an existing book:

- Added a simple “sidecar” instruction file next to the upload so the ingest worker knows to attach that file to the correct book (no duplicate books).

Maintain Google Drive sync:

- After a successful import or add‑format, we trigger the same GDrive sync used after metadata edits (only if GDrive enabled).

Added a little UX polish:

- Invalid new uploads now redirect to the home page; empty upload posts return “400 Bad Request.”
2025-08-22 12:24:27 +02:00
crocodilestick 5fbb82cd87 Fixed indentation errors 2025-08-20 09:54:33 +02:00
crocodilestick 5cdb27baaf Changed to auto_library.py to ignore sidecars ending with -wal, -shm, or -journal 2025-08-19 17:15:08 +02:00
crocodilestick 6d0eed3632 Fixed SPDX headers 2025-08-19 16:59:14 +02:00
crocodilestick 914f6c48f5 - Added an alternative/ fallback detection method to inotifywait (simple polling).
- Polling will also be used when NETWORK_SHARE_MODE is enabled as it has better reliability with shares and using polling over inotify can be activated manually by passing the CWA_WATCH_MODE: "poll" env variable
- If the user reaches max_user_watches limit, the cwa-ingest-service & metadata-change-detector processes will now dynamically fallback to polling

[bug] Synology - hitting inotify.max_user_watches limit
Fixes #311
[Feature Request] Skip actions on read-only data
Fixes #229
2025-08-19 16:58:41 +02:00
crocodilestick 22dcf9daf1 Made it so that cover_enforcer.py imports the helper script used for sanitizing filenames from helper.py to ensure parity between CWA script operations and the rest of the app. 2025-08-19 16:06:34 +02:00
crocodilestick 3eb87631e7 Enhance filename handling and encoding support in cover enforcer script
[bug] (special characters issue) New author subdirectory created under old author subdirectory after metadata update
Fixes #400
2025-08-19 13:17:26 +02:00
crocodilestick 91f97d46c7 Minor refactoring 2025-08-19 13:06:20 +02:00
crocodilestick b05d342db8 Made encoding more explicit at each stage to prevent potential encoding related errors 2025-08-19 12:46:04 +02:00
crocodilestick a719e14a6c SQLite stability and concurrency:
- Added connection timeouts everywhere:
SQLAlchemy engines: connect_args={'timeout': 30}
sqlite3 direct connects: timeout=30 across scripts

- Enabled WAL mode on local disks and made it conditional via an environment flag.
-Added small retry/backoff in read-only UI probes to tolerate transient “database is locked.”

Increased Network share support (NFS/SMB):

- Introduced NETWORK_SHARE_MODE to disable WAL and suppress permission-changing operations that can break on network filesystems.
- Suppressed recursive chown when NETWORK_SHARE_MODE is true:
Python:
scripts/auto_library.py: skip chown for /config and /calibre-library during app.db/new library setup
scripts/ingest_processor.py: skip chown of library in set_library_permissions
scripts/convert_library.py: skip chown of convert-library.log; skip library chown
scripts/kindle_epub_fixer.py: skip chown of epub-fixer.log
cps/updater.py: disable os.chown during updates when flag is enabled
Shell:
scripts/setup-cwa.sh: guard chown of /etc/s6-overlay
root/etc/s6-overlay/s6-rc.d/cwa-init/run: guard initial chown of /config and cps/cache; guard requiredDirs loop

Documentation and configuration:

- README: Added “Network shares and SQLite WAL mode” section; documented that NETWORK_SHARE_MODE disables WAL and chown behavior for safety on network shares.
- docker-compose.yml and docker-compose.yml.dev: Exposed NETWORK_SHARE_MODE (default false) in environment.
Fixed a minor YAML indentation issue during compose edits.

Impacts on the Project:

- Fewer “database is locked” errors due to timeouts, gentle retries, and WAL on local disks.
- Safer behavior on NFS/SMB: WAL disabled and chown suppressed when NETWORK_SHARE_MODE=true.
- Clearer guidance for users via README and compose templates.

[bug] chown failed
Fixes #175
Calibre-Web-automated [bug]
Fixes #530
2025-08-18 12:35:12 +02:00
Aymen Djellal 8e9741f3fc Update ingest_processor.py 2025-08-15 14:18:21 -04:00
crocodilestick aa5ca82a3a [bug] Changing Capitalization for one work of an author makes links to all works of the author break
Fixes #481

Problem: When editing book metadata (either in bulk, inline, or through the full-page editor), the function to update the book's directory structure on the filesystem (update_dir_structure) was called multiple times in quick succession or for each book in a selection. This created a race condition, leading to errors and inconsistent folder structures.
Solution: The editing functions in editbooks.py (edit_selected_books, edit_book_param, and do_edit_book) were refactored. The new workflow ensures that all database-level metadata changes are collected and staged first. Only after all changes are ready is the filesystem update function called a single time. This atomic operation prevents race conditions and ensures the directory structure accurately reflects the final state of the metadata.

[bug] Failing to update metadata due to filepath mismatch
Fixes #519

Problem: The cover_enforcer.py script, which processes metadata change logs, failed to correctly parse log entries for books with multiple authors (e.g., "Author One & Author Two"). It would use the entire string as the author's name, leading to incorrect directory paths and "File Not Found" errors.
Solution: The script was modified to correctly handle multi-author strings. It now splits the author field by the " & " delimiter and uses only the first author to construct the directory path, mirroring Calibre-Web's default behavior.
2025-08-13 16:23:34 +02:00
crocodilestick cef90185df Fixed spdx header script 2025-08-12 16:36:53 +02:00
crocodilestick a978996662 Fixed [bug] Authors interface has display bugs
Fixes #298
Now on all list.html based pages, filtering elements now collapse into a drop down if there would otherwise be too many to display neatly
2025-08-12 15:56:11 +02:00
crocodilestick ae32de361e Minor refactoring and bugfixes 2025-08-11 15:55:55 +02:00
crocodilestick 2c8276c753 Incorporated the init-calibre-web-config into cwa-init and changed running order so that cwa-init runs in the place of init-calibre-web-config and svc-calibre-web-automated runs after cwa-init 2025-08-11 14:55:39 +02:00
root 72991c03d6 Add ACSM format 2025-08-10 23:15:11 +00:00
crocodilestick b2ba3bc66d Fixes #496 2025-08-10 12:42:32 +02:00
crocodilestick 4dfbcba34d Reverted unwanted changes 2025-08-09 23:42:20 +02:00
crocodilestick 2dd19f913e REFACTOR - Centralized path management by creating paths.py to replace hard-coded paths across multiple scripts 2025-08-09 22:25:38 +02:00
crocodilestick 0c891d259f REFACTOR - Moved audiobook.py, auto_library.py, auto_zip.py, convert_library.py, cover_enforcer.py, cwa_db.py, cwa_functions.py, cwa_schema.sql, ingest_processor.py & kindle_epub_fixer.py to the cps dir, changing dependencies as necessary 2025-08-09 20:21:58 +02:00
crocodilestick 0153b3cf34 REFACTOR - Moved root scripts to scripts dir 2025-08-09 19:35:22 +02:00
crocodilestick 9259658821 Fixed spdx headers 2025-08-09 16:30:04 +02:00
crocodilestick d54e34d47f Updated spdx headers to more accurately reflect the current status of the project & it's contributors 2025-08-09 16:25:35 +02:00
crocodilestick 91f727529d Added "sexy-background-blur" option to cwa-settings to give mobile dark mode users the same cover incorporated background blur effect they have on desktop (can be disabled in cwa settings) 2025-08-09 11:56:30 +02:00
crocodilestick f9a22ea94d Added system to prompt users using CWA in languages other than English that has missing translations, to help complete the translations for that language. These notifications can be disabled in the CWA settings panel 2025-08-06 16:02:42 +02:00
crocodilestick 834e2cc250 Fixed bug where compile_translations.sh wasn't executable 2025-08-04 16:57:24 +02:00
crocodilestick 7f4eb34658 [bug]No option for other languages
Fixes #475
No dutch locale after updating to version 3.1.2
Fixes #466
2025-08-04 16:54:32 +02:00