Files
Calibre-Web-Automated/scripts/cwa_schema.sql
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

55 lines
2.2 KiB
SQL

CREATE TABLE IF NOT EXISTS cwa_enforcement(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
timestamp TEXT NOT NULL,
book_id INTEGER NOT NULL,
book_title TEXT NOT NULL,
author TEXT NOT NULL,
file_path TEXT NOT NULL,
trigger_type TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS cwa_import(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
timestamp TEXT NOT NULL,
filename TEXT NOT NULL,
original_backed_up TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS cwa_conversions(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
timestamp TEXT NOT NULL,
filename TEXT NOT NULL,
original_format TEXT NOT NULL,
original_backed_up TEXT NOT NULL,
end_format TEXT DEFAULT "" NOT NULL
);
CREATE TABLE IF NOT EXISTS epub_fixes(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
timestamp TEXT NOT NULL,
filename TEXT NOT NULL,
manually_triggered TEXT NOT NULL,
num_of_fixes_applied TEXT NOT NULL,
original_backed_up TEXT NOT NULL,
file_path TEXT NOT NULL,
fixes_applied TEXT DEFAULT ""
);
CREATE TABLE IF NOT EXISTS cwa_settings(
default_settings SMALLINT DEFAULT 1 NOT NULL,
auto_backup_imports SMALLINT DEFAULT 1 NOT NULL,
auto_backup_conversions SMALLINT DEFAULT 1 NOT NULL,
auto_zip_backups SMALLINT DEFAULT 1 NOT NULL,
cwa_update_notifications SMALLINT DEFAULT 1 NOT NULL,
contribute_translations_notifications SMALLINT DEFAULT 1 NOT NULL,
auto_convert SMALLINT DEFAULT 1 NOT NULL,
auto_convert_target_format TEXT DEFAULT "epub" NOT NULL,
auto_convert_ignored_formats TEXT DEFAULT "" NOT NULL,
auto_ingest_ignored_formats TEXT DEFAULT "" NOT NULL,
auto_ingest_automerge TEXT DEFAULT "new_record" NOT NULL,
ingest_timeout_minutes INTEGER DEFAULT 15 NOT NULL,
auto_metadata_enforcement SMALLINT DEFAULT 1 NOT NULL,
kindle_epub_fixer SMALLINT DEFAULT 1 NOT NULL,
auto_backup_epub_fixes SMALLINT DEFAULT 1 NOT NULL,
enable_mobile_blur SMALLINT DEFAULT 1 NOT NULL,
auto_metadata_fetch_enabled SMALLINT DEFAULT 0 NOT NULL,
auto_metadata_smart_application SMALLINT DEFAULT 0 NOT NULL,
metadata_provider_hierarchy TEXT DEFAULT '["ibdb","google","dnb"]' NOT NULL,
auto_send_delay_minutes INTEGER DEFAULT 5 NOT NULL
);