Skip to content

Commit 37f1fd6

Browse files
committed
Implement audiobook merge functionality
Add complete merge feature to combine MP3 chapters into M4B audiobooks: - Add MergeService with listr2 progress indicators - Implement FFmpeg integration with bundled binary - Add chapter markers using FFMETADATA1 format - Preserve stereo audio quality (64kbps AAC) - Add merge command to CLI and interactive menu - Include comprehensive test coverage (13 new tests) - Add research documentation for CLI progress libraries Dependencies added: - fluent-ffmpeg: FFmpeg Node.js wrapper - @ffmpeg-installer/ffmpeg: Bundled FFmpeg binary - listr2: Interactive task list UI Build configuration: - Update tsconfig to use CommonJS for Node compatibility - Fix module resolution for CLI execution All 201 tests passing.
1 parent 8fdea5e commit 37f1fd6

14 files changed

Lines changed: 1991 additions & 144 deletions

CLAUDE.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ TypeScript CLI tool for managing audiobooks downloaded from Libby via Chrome ext
99
npm run dev # Run interactive CLI
1010
npm run dev -- list # List downloaded books
1111
npm run dev -- tag # Tag MP3 files
12+
npm run dev -- merge # Merge chapters into M4B audiobook
1213

1314
# Testing & Validation
1415
npm test # Run Jest tests
@@ -44,7 +45,9 @@ npm run extension:lint # Lint with warnings-as-errors
4445
- `src/commands/interactive.ts` - Interactive menu system
4546
- `src/commands/list.ts` - List downloaded books
4647
- `src/commands/tag.ts` - Tag MP3 files with metadata
48+
- `src/commands/merge.ts` - Merge chapters into M4B audiobook
4749
- `src/metadata/embedder.ts` - ID3 tag embedding
50+
- `src/services/merge-service.ts` - M4B audiobook merging with FFmpeg
4851
- `src/utils/books.ts` - Book discovery and status checking
4952
- `src/utils/logger.ts` - Logging utilities
5053

@@ -108,10 +111,17 @@ npm run extension:lint # Lint with warnings-as-errors
108111
- Embeds ID3 tags into MP3 files (title, author, narrator, cover art)
109112
- Shows book status (tagged/untagged)
110113

114+
3. **CLI Merges (Optional):**
115+
- CLI can merge individual chapter MP3s into a single M4B audiobook
116+
- Uses fluent-ffmpeg with bundled ffmpeg binary (zero config)
117+
- Embeds chapter markers (one per MP3 file)
118+
- Includes metadata (title, author, narrator, cover art)
119+
- Output: 64kbps AAC mono (optimized for voice)
120+
111121
**Key Points:**
112122

113123
- Extension handles ALL downloading (no CLI download functionality)
114-
- CLI is ONLY for tagging and listing books
124+
- CLI is for tagging, merging, and listing books
115125
- No browser automation
116126
- No rate limiting in CLI (extension handles that)
117127
- Downloads happen in user's real browser session (zero bot detection)
@@ -227,6 +237,8 @@ export const DEBUG_MODE = true; // Set to false for production
227237
**Key packages:**
228238

229239
- `node-id3` for metadata embedding
240+
- `fluent-ffmpeg` for M4B audiobook creation
241+
- `@ffmpeg-installer/ffmpeg` for bundled ffmpeg binary (~50MB, cross-platform)
230242
- `commander` for CLI
231243
- `chalk` for terminal UI
232244
- `inquirer` for interactive prompts
@@ -352,9 +364,10 @@ All innerHTML security warnings have been fixed by using textContent instead.
352364

353365
**Available Commands:**
354366

355-
- `libby` - Interactive menu (tag files, list books, view details)
367+
- `libby` - Interactive menu (tag files, merge chapters, list books, view details)
356368
- `libby list` - List all downloaded books with status
357369
- `libby tag [folder]` - Tag MP3 files with metadata (interactive if no folder)
370+
- `libby merge [folder]` - Merge MP3 chapters into single M4B audiobook (interactive if no folder)
358371

359372
**Command Options:**
360373

0 commit comments

Comments
 (0)