/** * Component: E-book Settings Tab * Documentation: documentation/settings-pages.md * * Three-section layout: * 1. Anna's Archive - Direct HTTP downloads from Anna's Archive * 2. Indexer Search - Search via Prowlarr indexers (future feature) * 3. General Settings - Shared settings like preferred format */ 'use client'; import React from 'react'; import { Button } from '@/components/ui/Button'; import { Input } from '@/components/ui/Input'; import { useEbookSettings } from './useEbookSettings'; import type { EbookSettings } from '../../lib/types'; interface EbookTabProps { ebook: EbookSettings; onChange: (ebook: EbookSettings) => void; onSuccess: (message: string) => void; onError: (message: string) => void; markAsSaved: () => void; } export function EbookTab({ ebook, onChange, onSuccess, onError, markAsSaved }: EbookTabProps) { const { saving, testingFlaresolverr, flaresolverrTestResult, updateEbook, testFlaresolverrConnection, saveSettings, isAnySourceEnabled, } = useEbookSettings({ ebook, onChange, onSuccess, onError, markAsSaved }); return (
{/* Header */}

E-book Sidecar

Automatically download e-books to accompany your audiobooks. E-books are placed in the same folder as the audiobook files.

{/* ═══════════════════════════════════════════════════════════════════════ SECTION 1: ANNA'S ARCHIVE ═══════════════════════════════════════════════════════════════════════ */}

Anna's Archive

{/* Enable Toggle */}
updateEbook('annasArchiveEnabled', e.target.checked)} className="mt-1 h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500" />

Download e-books directly from Anna's Archive using ASIN or title matching.

{/* Anna's Archive specific settings - only shown when enabled */} {ebook.annasArchiveEnabled && ( <> {/* Base URL */}
updateEbook('baseUrl', e.target.value)} placeholder="https://annas-archive.gl" className="font-mono" />

Change this if the primary Anna's Archive mirror is unavailable.

{/* FlareSolverr URL */}
updateEbook('flaresolverrUrl', e.target.value)} placeholder="http://localhost:8191" className="font-mono flex-1" />

FlareSolverr helps bypass Cloudflare protection.

{flaresolverrTestResult && (
{flaresolverrTestResult.success ? '✓ ' : '✗ '} {flaresolverrTestResult.message}
)}
{!ebook.flaresolverrUrl && (

Note: Without FlareSolverr, e-book downloads may fail if Anna's Archive has Cloudflare protection enabled.

)}
)}
{/* ═══════════════════════════════════════════════════════════════════════ SECTION 2: INDEXER SEARCH ═══════════════════════════════════════════════════════════════════════ */}

Indexer Search

{/* Enable Toggle */}
updateEbook('indexerSearchEnabled', e.target.checked)} className="mt-1 h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500" />

Search for e-books via Prowlarr indexers (torrent/NZB sources).

{/* Info hint about indexer settings */} {ebook.indexerSearchEnabled && (

Configure Categories: E-book category settings are configured per-indexer in the Indexers tab. Look for the "EBook" tab when editing an indexer.

)}
{/* ═══════════════════════════════════════════════════════════════════════ SECTION 3: GENERAL SETTINGS ═══════════════════════════════════════════════════════════════════════ */} {isAnySourceEnabled && (

General Settings

{/* Preferred Format */}

EPUB is recommended for most e-readers. "Any format" accepts the first available.

{/* Auto Grab Toggle */}
updateEbook('autoGrabEnabled', e.target.checked)} className="mt-1 h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500" />

When enabled, ebook requests are created automatically after audiobook downloads complete. When disabled, use the "Fetch Ebook" button on completed requests.

{/* Kindle Fix Toggle - Only shown when EPUB is selected */} {(ebook.preferredFormat === 'epub' || !ebook.preferredFormat) && (
updateEbook('kindleFixEnabled', e.target.checked)} className="mt-1 h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500" />

Apply compatibility fixes before organizing EPUB files. Fixes encoding declarations, broken hyperlinks, invalid language tags, and orphaned image elements that can cause Kindle import failures.

)}
)} {/* How it works - only show when Anna's Archive is enabled */} {ebook.annasArchiveEnabled && (

How Anna's Archive works

)} {/* Save Button */}
); }