Skip to content

Conversation

@nullable-eth
Copy link
Owner

@nullable-eth nullable-eth commented Jul 2, 2025

🔄 Major Refactor: Unified Media Processing & Enhanced Documentation

This PR introduces significant architectural improvements and BREAKING CHANGES that require configuration updates.

⚠️ BREAKING CHANGES

Environment Variable Changes

  • LIBRARY_IDMOVIE_LIBRARY_ID (renamed for clarity with TV support)
  • No default library processing: Application now requires explicit library configuration

Library Selection Behavior

  • Previous: Auto-selected first movie library if no LIBRARY_ID specified
  • New: Requires explicit configuration - processes NO libraries by default
  • Migration required: Users must add MOVIE_PROCESS_ALL=true or specify MOVIE_LIBRARY_ID

🚨 Migration Required

For Existing Users

Old configuration:

# This would auto-select first movie library
docker run -e PLEX_TOKEN=... ghcr.io/nullable-eth/labelarr:latest

New configuration (choose one):

# Option 1: Process all movie libraries
docker run -e PLEX_TOKEN=... -e MOVIE_PROCESS_ALL=true ghcr.io/nullable-eth/labelarr:latest

# Option 2: Process specific movie library  
docker run -e PLEX_TOKEN=... -e MOVIE_LIBRARY_ID=1 ghcr.io/nullable-eth/labelarr:latest

# Option 3: Process both movies and TV shows
docker run -e PLEX_TOKEN=... -e MOVIE_PROCESS_ALL=true -e TV_PROCESS_ALL=true ghcr.io/nullable-eth/labelarr:latest

🏗️ Core Architecture Changes

Unified Media Processor

  • Consolidated processors: Eliminated separate movie and TV processors that had ~95% identical code
  • Generic implementation: Single Processor handles both movies and TV shows with type-specific configurations
  • Reduced codebase: ~79-80% code reduction with improved maintainability
  • Type-based processing: Uses MediaType parameter from main instead of runtime detection

Simplified Plex Client

  • Generic methods: Replaced 4 separate functions with 2 generic ones:
    • UpdateMovieField + UpdateTVShowFieldUpdateMediaField
    • RemoveMovieFieldKeywords + RemoveTVShowFieldKeywordsRemoveMediaFieldKeywords
  • Removed unnecessary lockField parameter from updateMediaField()
  • 33% function reduction with cleaner, more maintainable design

🗂️ File Structure Changes

Deleted files (consolidated functionality):

  • internal/movie/processor.go
  • internal/tv/processor.go
  • internal/media/unified_processor.go
  • internal/media/new_processor.go

Updated files:

  • internal/media/processor.go - Single, generic processor implementation
  • internal/plex/client.go - Unified media field operations
  • cmd/labelarr/main.go - Simplified processor initialization

📚 Documentation Enhancements

Comprehensive Radarr Troubleshooting Section

  • 🎬 Radarr-specific guidance: Step-by-step configuration for TMDb ID inclusion
  • 📝 Naming scheme examples: Multiple format options ({tmdb-{TmdbId}}, [tmdb-{TmdbId}], etc.)
  • ❌ Common pitfalls: Missing TMDb IDs, IMDb vs TMDb confusion, folder vs file naming
  • 🔧 Migration guidance: Mass rename instructions for existing libraries
  • 📁 Directory structure examples: Real-world file organization patterns

🆕 New Features

TV Show Support

  • Complete TV library processing: Full TMDb keyword integration for TV shows
  • Explicit library control: Choose exactly which libraries to process
  • Dual media support: Can process movies, TV shows, or both simultaneously

🚀 Benefits

For Users

  • TV show support: Now works with both movies and TV shows
  • Better control: Explicit library selection instead of auto-selection
  • Improved documentation: Clear troubleshooting for common Radarr issues
  • Reduced verbosity: Quieter processing output, only shows new items and errors

For Developers

  • Maintainability: Single source of truth for media processing logic
  • Extensibility: Easy to add new media types with minimal code changes
  • Code quality: Eliminated duplication, cleaner interfaces, better separation of concerns

🔄 Why These Breaking Changes?

  1. TV Support Necessity: With TV show support, users might want to process only TV shows without movies
  2. Clearer Intent: Auto-selection made assumptions about user intentions
  3. Future Flexibility: Explicit configuration allows for more granular control
  4. Naming Clarity: MOVIE_LIBRARY_ID vs TV_LIBRARY_ID is much clearer than generic LIBRARY_ID

🧪 Testing

  • Compilation verified: go build ./... and go build ./cmd/labelarr
  • Functionality preserved: All movie processing capabilities maintained
  • New TV functionality: Complete TV show processing implementation
  • Migration verified: Old configurations fail gracefully with clear error messages

📋 Migration Checklist for Users

  • Update environment variables (LIBRARY_IDMOVIE_LIBRARY_ID)
  • Add explicit library processing flags (MOVIE_PROCESS_ALL=true or TV_PROCESS_ALL=true)
  • Test configuration before deploying to production
  • Review logs to ensure expected libraries are being processed

This major version represents a significant improvement in architecture and functionality, but requires configuration updates for existing users.

also update structure to more maintainable modularized packages.
@nullable-eth nullable-eth merged commit 2444804 into main Jul 2, 2025
1 check passed
@nullable-eth nullable-eth deleted the add-tv-processing branch July 2, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants