Implement chapter merging feature and update ranking algorithm

Added automatic chapter merging to M4B with admin/config toggles, UI controls, and backend logic. Updated documentation to reflect implementation. Refactored ranking algorithm: increased Title/Author match points, removed size scoring, and improved Usenet/torrent handling. Enhanced Prowlarr integration for protocol detection and filtering. Improved file organizer to support chapter merging. Various bug fixes and logging improvements.
This commit is contained in:
kikootwo
2026-01-08 16:26:26 -05:00
parent 722a78ac33
commit 288421012d
21 changed files with 922 additions and 128 deletions
+2 -2
View File
@@ -48,7 +48,7 @@
- **qBittorrent integration (torrents)** → [phase3/qbittorrent.md](phase3/qbittorrent.md)
- **SABnzbd integration (Usenet/NZB)** → [phase3/sabnzbd.md](phase3/sabnzbd.md)
- **File organization, seeding** → [phase3/file-organization.md](phase3/file-organization.md)
- **Chapter merging (PRD, not implemented)** → [features/chapter-merging.md](features/chapter-merging.md)
- **Chapter merging (auto-merge to M4B)** → [features/chapter-merging.md](features/chapter-merging.md)
## Background Jobs
- **Bull queue, processors, retry logic** → [backend/services/jobs.md](backend/services/jobs.md)
@@ -93,7 +93,7 @@
**"How do I use the unified container?"** → [deployment/unified.md](deployment/unified.md)
**"OAuth redirects to localhost / PUBLIC_URL not working"** → [backend/services/environment.md](backend/services/environment.md)
**"What environment variables do I need?"** → [backend/services/environment.md](backend/services/environment.md)
**"How does chapter merging work?"** → [features/chapter-merging.md](features/chapter-merging.md) (PRD only, not implemented)
**"How does chapter merging work?"** → [features/chapter-merging.md](features/chapter-merging.md)
**"How does Audiobookshelf integration work?"** → [features/audiobookshelf-integration.md](features/audiobookshelf-integration.md) (PRD only, not implemented)
**"How do I use OIDC/Authentik/Keycloak?"** → [features/audiobookshelf-integration.md](features/audiobookshelf-integration.md) (PRD only, not implemented)
**"How does manual user registration work?"** → [features/audiobookshelf-integration.md](features/audiobookshelf-integration.md) (PRD only, not implemented)
+1 -1
View File
@@ -1,6 +1,6 @@
# Chapter Merging Feature
**Status:** ❌ Not Started | Product Requirements Document
**Status:** ✅ Implemented | Auto-merge multi-file chapters to M4B
## Overview
+4 -10
View File
@@ -6,7 +6,7 @@ Evaluates and scores torrents to automatically select best audiobook download.
## Scoring Criteria (100 points max)
**1. Title/Author Match (50 pts max) - MOST IMPORTANT**
**1. Title/Author Match (60 pts max) - MOST IMPORTANT**
**Multi-Stage Matching:**
@@ -24,7 +24,7 @@ Evaluates and scores torrents to automatically select best audiobook download.
- "Dennis E. Taylor - Bobiverse - 01 - We Are Legion" → 3/3 = 100% → **PASSES**
- Prevents wrong series books from matching while handling common subtitle patterns
**Stage 2: Title Matching (0-35 pts)**
**Stage 2: Title Matching (0-45 pts)**
- Only scored if Stage 1 passes
- **Tries full title first, then required title (without parentheses)** if no match
- Example: "We Are Legion (We Are Bob)" tries both full title and "We Are Legion"
@@ -35,7 +35,7 @@ Evaluates and scores torrents to automatically select best audiobook download.
- Title preceded by metadata separator (` - `, `: `, `—`) — handles "Author - Series - 01 - Title"
- Author name appears in prefix — handles "Author Name - Title"
- **Acceptable suffix**: Followed by metadata markers: " by", " [", " -", " (", " {", " :", "," or end of string
- Complete match → 35 pts
- Complete match → 45 pts
- Unstructured prefix (words without separators) → fuzzy similarity (partial credit)
- Prevents: "This Inevitable Ruin Dungeon Crawler Carl" matching "Dungeon Crawler Carl"
- Suffix continues with non-metadata → fuzzy similarity (partial credit)
@@ -61,12 +61,7 @@ Evaluates and scores torrents to automatically select best audiobook download.
**3. Seeder Count (15 pts max)**
- Formula: `Math.min(15, Math.log10(seeders + 1) * 6)`
- 1 seeder: 0pts, 10 seeders: 6pts, 100 seeders: 12pts, 1000+: 15pts
**4. Size Reasonableness (10 pts max)**
- Expected: 1-2 MB/min (64-128 kbps)
- Perfect match: 10 pts
- Deviation → penalty
- Unknown duration: 5 pts (neutral)
- Note: Usenet/NZB results without seeders get full 15 pts (centralized availability)
## Bonus Points System
@@ -148,7 +143,6 @@ interface RankedTorrent extends TorrentResult {
breakdown: {
formatScore: number;
seederScore: number;
sizeScore: number;
matchScore: number;
totalScore: number; // Same as score
notes: string[];