Skip to content

Conversation

@nullable-eth
Copy link
Owner

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

🔍 Enhance TMDb ID Detection with Flexible Regex Pattern

Summary

Improves the TMDb ID extraction regex to support a much wider variety of file and folder naming patterns, making Labelarr compatible with more diverse media library setups.

What Changed

  • Enhanced regex pattern for ExtractTMDbIDFromPath() function
  • Expanded pattern matching to support various separators, brackets, and formatting styles
  • Added comprehensive test suite with 25+ test cases covering real-world scenarios

New Supported Patterns

Direct Concatenation:

  • tmdb603, TMDB27205, Tmdb19995

With Separators:

  • tmdb:157336, tmdb-155, tmdb_680, tmdb=550, tmdb 278

With Brackets/Braces:

  • {tmdb634}, [tmdb-13], (tmdb:238), {tmdb=103}, (tmdb 289)

Complex Real-World Examples:

  • /movies/The Matrix (1999) [1080p] {tmdb-603} [x264]/file.mkv
  • /movies/Inception (2010) {tmdb-27205} [Bluray-1080p][x264][DTS 5.1]-GROUP/file.mkv

Benefits

  • 🎯 Better compatibility with Radarr/Sonarr naming schemes
  • 📁 Flexible file organization - works with various bracket/separator preferences
  • 🔄 Backward compatibility - all existing patterns still work
  • 🛡️ Robust edge case handling - prevents false matches
  • ⚡ Performance tested - includes benchmark tests

Testing

  • 25+ test cases covering supported and unsupported patterns
  • Edge case validation for boundary conditions
  • Benchmark tests to ensure regex performance
  • Real-world examples from actual media libraries

Breaking Changes

None - this is a backward-compatible enhancement that expands matching capabilities.


Fixes: Improves TMDb ID detection for users with diverse naming conventions
Related: Addresses compatibility issues with various media management tools

@nullable-eth nullable-eth merged commit d5fab3d into main Jul 3, 2025
1 check passed
@nullable-eth nullable-eth deleted the fix-tmdb-regex branch July 3, 2025 00:49
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