mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
Add series fields to audiobooks and update related logic
Introduces 'series' and 'seriesPart' fields to the Audiobook model and database schema. Updates API routes, file organization, and path template utilities to support series metadata. Enhances chapter merging logic, improves notification backend testing, and expands test coverage for admin and API routes.
This commit is contained in:
@@ -164,14 +164,14 @@ ffmpeg -y -f concat -safe 0 -i filelist.txt \
|
||||
**For MP3 files (requires conversion - v2 enhanced):**
|
||||
```bash
|
||||
# Re-encode to M4B (AAC) with quality preservation
|
||||
# Uses libfdk_aac if available (higher quality) or native aac
|
||||
# Uses libfdk_aac if available (higher quality) or native aac with VBR
|
||||
ffmpeg -y -f concat -safe 0 -i filelist.txt \
|
||||
-i chapters.txt \
|
||||
-map_metadata 1 \
|
||||
-map 0:a \
|
||||
-c:a libfdk_aac -vbr 4 \ # High quality AAC (or: -c:a aac -b:a <source_bitrate> -profile:a aac_low)
|
||||
-c:a libfdk_aac -vbr 4 \ # High quality AAC (or: -c:a aac -q:a <quality> -profile:a aac_low)
|
||||
-movflags +faststart \ # CRITICAL: Instant playback
|
||||
-fflags +genpts \ # Fix timestamps
|
||||
-fflags +genpts \ # Fix timestamps (regenerates presentation timestamps)
|
||||
-avoid_negative_ts make_zero \ # Handle edge cases
|
||||
-max_muxing_queue_size 9999 \ # Long file support
|
||||
-metadata title="Book Title" \
|
||||
@@ -182,16 +182,18 @@ ffmpeg -y -f concat -safe 0 -i filelist.txt \
|
||||
|
||||
**Quality Settings (MP3 → M4B - v2):**
|
||||
- **Bitrate:** Matches source average (64-320kbps range)
|
||||
- Example: 128kbps MP3 source → 128kbps AAC output
|
||||
- Example: 192kbps MP3 source → 192kbps AAC output
|
||||
- **Encoder:** libfdk_aac (VBR mode 4, high quality) if available, else native aac
|
||||
- Example: 128kbps MP3 source → ~128kbps AAC output
|
||||
- Example: 192kbps MP3 source → ~192kbps AAC output
|
||||
- **Encoder:** libfdk_aac (VBR mode 4, high quality) if available, else native aac with VBR
|
||||
- Native AAC uses variable bitrate for better quality/efficiency
|
||||
- Quality mapped dynamically: 64k→q1.0, 128k→q2.0, 192k→q3.0, 256k→q4.0
|
||||
- **Profile:** AAC-LC (maximum compatibility)
|
||||
- **Sampling rate:** Preserved from source
|
||||
- **Channels:** Preserved (mono/stereo)
|
||||
|
||||
**Critical Flags (v2):**
|
||||
- **`-movflags +faststart`**: Moves moov atom to file beginning → instant playback (fixes 1-min delay)
|
||||
- **`-fflags +genpts`**: Regenerates presentation timestamps → fixes seeking/timing issues
|
||||
- **`-fflags +genpts`**: Regenerates presentation timestamps for audio/video → fixes seeking/timing issues at concat boundaries
|
||||
- **`-avoid_negative_ts make_zero`**: Handles negative timestamps at concat boundaries
|
||||
- **`-max_muxing_queue_size 9999`**: Prevents buffer overflow on long audiobooks (16h+)
|
||||
|
||||
@@ -466,8 +468,8 @@ timeout = 5 minutes + (chapter_count * 30 seconds)
|
||||
All merged files are validated before marked successful:
|
||||
|
||||
1. **Duration Check:** Expected vs actual duration (within 2% tolerance)
|
||||
2. **Decode Test:** FFmpeg attempts to decode first 10 seconds (catches corruption)
|
||||
3. **Size Check:** File size reasonable for duration (~0.5MB/min minimum)
|
||||
2. **Decode Test:** FFmpeg attempts to decode first and last 10 seconds (catches corruption/truncation)
|
||||
3. **Size Check:** File size reasonable for duration (~0.4MB/min minimum, accommodates 64kbps encoding)
|
||||
|
||||
**If validation fails:**
|
||||
- Corrupt file is deleted
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
# Testing
|
||||
|
||||
**Status:** ⏳ In Progress | Backend unit testing framework (Vitest)
|
||||
**Status:** ƒ?3 In Progress | Backend + frontend unit testing framework (Vitest)
|
||||
|
||||
## Overview
|
||||
Unit tests for backend logic with isolated mocks (Prisma, integrations, queue).
|
||||
Backend unit tests (Node) and frontend component tests (jsdom) with isolated mocks and deterministic helpers.
|
||||
|
||||
## Key Details
|
||||
- **Runner:** Vitest (`vitest.config.ts`, Node environment)
|
||||
- **Setup:** `tests/setup.ts` sets `NODE_ENV=test`, `TZ=UTC`, blocks unmocked fetch
|
||||
- **Helpers:** `tests/helpers/prisma.ts`, `tests/helpers/job-queue.ts`
|
||||
- **Runner:** Vitest (`vitest.config.ts`)
|
||||
- **Environments:** Node for `*.test.ts`, jsdom for `*.test.tsx` via `environmentMatchGlobs`
|
||||
- **Setup:** `tests/setup.ts` sets `NODE_ENV=test`, `TZ=UTC`, jest-dom, DOM polyfills, Next.js `Link/Image` mocks
|
||||
- **Frontend helpers:** `tests/helpers/render.tsx`, `tests/helpers/mock-auth.ts`, `tests/helpers/mock-next-navigation.ts`
|
||||
- **Backend helpers:** `tests/helpers/prisma.ts`, `tests/helpers/job-queue.ts`
|
||||
- **GitHub Actions:** Manual workflow `.github/workflows/manual-tests.yml` runs `npm test`
|
||||
- **Coverage:** `npm run test:coverage` (reports in `coverage/`)
|
||||
- **Scope:** Backend unit tests only; no real network or services
|
||||
- **Scope:** Unit tests only; no real network or services
|
||||
|
||||
## API/Interfaces
|
||||
```
|
||||
@@ -21,8 +23,10 @@ npm run test:coverage
|
||||
```
|
||||
|
||||
## Critical Issues
|
||||
- API route unit tests are incomplete; add route-level mocks before enforcing coverage.
|
||||
- Frontend coverage not yet enforced; expand component/page tests before adding coverage gates.
|
||||
|
||||
## Related
|
||||
- [frontend/components.md](frontend/components.md)
|
||||
- [frontend/routing-auth.md](frontend/routing-auth.md)
|
||||
- [backend/services/jobs.md](backend/services/jobs.md)
|
||||
- [backend/services/scheduler.md](backend/services/scheduler.md)
|
||||
|
||||
Reference in New Issue
Block a user