Add Plex format coercion (.mp4 → .m4b)

Implement Plex-compatible file-extension coercion to avoid Plex silently ignoring .mp4 (and single-file .m4a) audiobooks (issue #166). Adds a DB migration and configuration key (plex_format_coercion_enabled, default true), exposes a toggle in the setup wizard and Admin Paths settings, and persists/reads the setting in the admin/setup APIs.

Introduces src/lib/utils/format-coercion.ts (coerceToPlexCompatible) and related constants in src/lib/constants/audio-formats.ts (PLEX_COMPATIBLE_EXTENSIONS, COERCION_RENAME_MAP, DRM_EXTENSIONS, TRANSCODE_REQUIRED_EXTENSIONS). The organize-files processor now runs coercion after organizing/tagging and before generating the filesHash and triggering scans; coercion is idempotent, never overwrites existing targets, logs warnings on DRM/transcode/permission errors, and is non-fatal.

Adds unit tests for the coercion util and updates processor & setup UI tests. Updates documentation (TABLEOFCONTENTS, file-organization, fixes/file-hash-matching, settings-pages) describing behavior, config, and constraints.
This commit is contained in:
kikootwo
2026-05-15 19:33:59 -04:00
parent 6f8ac86a43
commit f23afc1ba2
18 changed files with 815 additions and 7 deletions
+20 -1
View File
@@ -23,6 +23,7 @@ const PathsHarness = ({
downloadDir: '/downloads',
mediaDir: '/media/audiobooks',
metadataTaggingEnabled: true,
plexFormatCoercionEnabled: true,
chapterMergingEnabled: false,
...initialState,
});
@@ -84,7 +85,11 @@ describe('PathsStep', () => {
<PathsHarness
onNext={vi.fn()}
onBack={vi.fn()}
initialState={{ metadataTaggingEnabled: false, chapterMergingEnabled: false }}
initialState={{
metadataTaggingEnabled: false,
plexFormatCoercionEnabled: false,
chapterMergingEnabled: false,
}}
/>
);
@@ -97,4 +102,18 @@ describe('PathsStep', () => {
expect(metadataToggle).toBeChecked();
expect(chapterToggle).toBeChecked();
});
it('renders plex format coercion toggle with default checked and toggles state', async () => {
render(<PathsHarness onNext={vi.fn()} onBack={vi.fn()} />);
const coercionToggle = screen.getByLabelText('Coerce file formats for Plex compatibility');
expect(coercionToggle).toBeChecked();
fireEvent.click(coercionToggle);
expect(coercionToggle).not.toBeChecked();
fireEvent.click(coercionToggle);
expect(coercionToggle).toBeChecked();
});
});