Skip to content

Commit 0b7f64e

Browse files
authored
Merge pull request #9 from ttlequals0/main
feature: Enhanced Labelarr with Radarr/Sonarr Integration and Keyword Normalization
2 parents c564c0d + 87867e4 commit 0b7f64e

File tree

17 files changed

+2494
-50
lines changed

17 files changed

+2494
-50
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,9 @@ build/
5151

5252
# Exclude build scripts and README
5353
build-and-deploy.sh
54-
build-and-deploy.ps1
54+
build-and-deploy.ps1
55+
56+
# Claude AI specific files
57+
.claude
58+
CLAUDE.md
59+
PR_DESCRIPTION.md

CHANGELOG.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Changelog
2+
3+
## [Unreleased] - 2025-07-05
4+
5+
### Added
6+
7+
#### Radarr/Sonarr Integration
8+
- ✅ Created Radarr API client module (`internal/radarr/`) with full API support
9+
- Movie search by title, year, TMDb ID, IMDb ID, and file path
10+
- Automatic TMDb ID extraction from Radarr database
11+
- Connection testing and system status endpoints
12+
13+
- ✅ Created Sonarr API client module (`internal/sonarr/`) with full API support
14+
- TV series search by title, year, TMDb ID, TVDb ID, IMDb ID, and file path
15+
- Episode fetching and file path matching
16+
- Connection testing and system status endpoints
17+
18+
- ✅ Updated configuration system to support Radarr/Sonarr
19+
- Added `USE_RADARR` and `USE_SONARR` environment variables
20+
- Added `RADARR_URL`, `RADARR_API_KEY`, `SONARR_URL`, `SONARR_API_KEY` configuration
21+
- Added validation for Radarr/Sonarr settings when enabled
22+
23+
- ✅ Enhanced TMDb ID extraction to use multiple sources
24+
- Primary: Plex metadata (existing functionality preserved)
25+
- Secondary: Radarr/Sonarr API matching (new)
26+
- Fallback: File path regex matching (existing functionality preserved)
27+
- Added source tracking to show where TMDb ID was found
28+
29+
- ✅ Updated media processor to integrate with Radarr/Sonarr
30+
- Modified `extractMovieTMDbID` to query Radarr when enabled
31+
- Modified `extractTVShowTMDbID` to query Sonarr when enabled
32+
- Added multiple matching strategies: title/year, IMDb ID, TVDb ID, file path
33+
34+
- ✅ Updated main application to initialize Radarr/Sonarr clients
35+
- Added connection testing on startup
36+
- Graceful handling when Radarr/Sonarr are not configured
37+
38+
- ✅ Created comprehensive docker-compose.yml example
39+
- Includes all existing configuration options
40+
- Added Radarr/Sonarr configuration examples with defaults
41+
42+
#### Verbose Logging & Debugging
43+
44+
- ✅ Added verbose logging feature
45+
- New `VERBOSE_LOGGING` environment variable (default: false)
46+
- Shows detailed TMDb ID lookup process for each item
47+
- Displays all available Plex GUIDs (IMDb, TMDb, TVDb)
48+
- Shows Radarr lookup attempts with title, file path, and IMDb ID matching
49+
- Shows Sonarr lookup attempts with title, TVDb ID, IMDb ID, and file path matching
50+
- Indicates source of successful TMDb ID matches
51+
- Helps troubleshoot matching issues
52+
53+
- ✅ Added progress tracking for large libraries
54+
- Shows percentage progress for libraries with >100 items
55+
- Displays current processing status
56+
- Shows summary of skipped items in verbose mode
57+
58+
- ✅ Enhanced label/genre application logging
59+
- Shows when keywords are being applied to Plex
60+
- Displays Plex API call timing in verbose mode
61+
- Shows current and new keywords being merged
62+
- Confirms successful application to Plex
63+
64+
#### Persistent Storage
65+
66+
- ✅ Added persistent storage for processed items
67+
- Prevents reprocessing items after container restarts
68+
- JSON file-based storage with atomic writes
69+
- Tracks which field (label/genre) was updated for each item
70+
- Configurable data directory via DATA_DIR environment variable
71+
- Docker volume support for data persistence
72+
- Storage directory defaults to `/data` in container
73+
74+
#### Error Handling & Connection Testing
75+
76+
- ✅ Added TMDb API connection testing on startup
77+
- Validates API token before processing begins
78+
- Provides clear error messages for authentication failures
79+
- Shows detailed error responses for debugging
80+
81+
- ✅ Improved error handling throughout
82+
- Better error messages for TMDb API failures
83+
- Clear indication of authentication vs other errors
84+
- Verbose mode shows why items are skipped
85+
86+
### Changed
87+
88+
- Modified `NewProcessor` to accept optional Radarr/Sonarr clients and return error
89+
- Enhanced TMDb ID detection to show source (Plex metadata, Radarr, Sonarr, or file path)
90+
- Processor initialization now includes persistent storage setup
91+
- Main application now tests all API connections on startup
92+
93+
### Documentation
94+
95+
- ✅ Updated README.md with comprehensive documentation
96+
- Added Radarr/Sonarr Integration section with benefits and configuration
97+
- Added Verbose Logging section with examples
98+
- Updated environment variables documentation
99+
- Added persistent storage information
100+
- Updated docker-compose examples
101+
102+
- ✅ Created detailed CHANGELOG.md
103+
- Comprehensive list of all changes
104+
- Organized by feature area
105+
- Technical implementation details
106+
107+
#### Keyword Normalization
108+
109+
- ✅ Added intelligent keyword normalization feature
110+
- Automatically normalizes TMDb keywords for consistent formatting
111+
- Pattern-based recognition for dynamic handling without hardcoding
112+
- Smart title casing with proper article and preposition handling
113+
- Automatic duplicate removal after normalization
114+
115+
- ✅ Pattern Recognition Features
116+
- **Critical Replacements**: Known abbreviations (sci-fi → Sci-Fi, romcom → Romantic Comedy)
117+
- **Acronym Detection**: Automatically uppercases known acronyms (FBI, CIA, DEA, etc.)
118+
- **Agency Patterns**: Detects agency roles (dea agent → DEA Agent)
119+
- **Parenthetical Acronyms**: Handles acronyms in parentheses (central intelligence agency (cia) → Central Intelligence Agency (CIA))
120+
- **Century Patterns**: Properly formats centuries (5th century bc → 5th Century BC)
121+
- **City/State Patterns**: Handles location formatting (san francisco, california → San Francisco, California)
122+
- **Relationship Patterns**: Adds "Relationship" where appropriate (father daughter → Father Daughter Relationship)
123+
- **Credit Stinger Terms**: Expands compound terms (duringcreditsstinger → During Credits Stinger)
124+
125+
- ✅ Added comprehensive test suite
126+
- 90+ test cases covering various normalization scenarios
127+
- Tests for edge cases, mixed case preservation, and pattern matching
128+
- Ensures consistent behavior across different keyword types
129+
130+
- ✅ Smart duplicate cleaning functionality
131+
- Automatically removes old unnormalized keywords when adding normalized versions
132+
- Preserves manually set keywords in Plex
133+
- Prevents accumulation of duplicate keywords (e.g., both "sci-fi" and "Sci-Fi")
134+
- Shows cleaning activity in verbose logging mode
135+
136+
#### Force Update Mode
137+
138+
- ✅ Added force update functionality
139+
- New `FORCE_UPDATE` environment variable (default: false)
140+
- Reprocesses all items regardless of previous processing status
141+
- Useful for applying keyword normalization to existing libraries
142+
- Shows clear indication when force update mode is active
143+
- Bypasses both storage checks and "already has keywords" logic
144+
145+
### Changed
146+
147+
- Modified `NewProcessor` to accept optional Radarr/Sonarr clients and return error
148+
- Enhanced TMDb ID detection to show source (Plex metadata, Radarr, Sonarr, or file path)
149+
- Processor initialization now includes persistent storage setup
150+
- Main application now tests all API connections on startup
151+
- TMDb client now normalizes all keywords before returning them
152+
- Updated keyword display to show normalization in verbose mode
153+
- Enhanced keyword synchronization with smart duplicate cleaning
154+
- Force update mode bypasses all previous processing checks
155+
156+
### Documentation
157+
158+
- ✅ Updated README.md with comprehensive documentation
159+
- Added Radarr/Sonarr Integration section with benefits and configuration
160+
- Added Verbose Logging section with examples
161+
- Added Keyword Normalization section with pattern examples
162+
- Added Force Update Mode section with use cases and examples
163+
- Added Smart Duplicate Cleaning documentation
164+
- Updated environment variables documentation
165+
- Added persistent storage information
166+
- Updated docker-compose examples
167+
168+
- ✅ Created detailed CHANGELOG.md
169+
- Comprehensive list of all changes
170+
- Organized by feature area
171+
- Technical implementation details
172+
173+
### Technical Details
174+
- Radarr/Sonarr clients use API v3 endpoints
175+
- Implemented robust error handling and fallback mechanisms
176+
- No breaking changes - Radarr/Sonarr integration is fully optional
177+
- Maintains backward compatibility with existing file path matching
178+
- Verbose logging provides detailed insights without affecting normal operation
179+
- Keyword normalization uses regex patterns for scalability
180+
- All features are designed to be non-breaking and backward compatible

0 commit comments

Comments
 (0)