feat: Add dedicated failed movies debug log
Local Docker Build (Dev) / build-dev (push) Successful in 24s
Local Docker Build (Main) / build (pull_request) Successful in 20s
Local Docker Build (Main) / deploy (pull_request) Has been skipped

- Create logs/failed_movies.log for movies with no_valid_date_source
- Logs movie name, IMDb ID, failure reason, and timestamp
- Helps users identify problematic movies needing manual attention
- Useful for debugging API issues and monitoring system health
- Documented in SUMMARY.md action items for troubleshooting workflow
This commit is contained in:
2025-09-24 14:10:02 -04:00
parent aa9f9d9194
commit bd7538abbd
2 changed files with 28 additions and 0 deletions
+2
View File
@@ -204,6 +204,7 @@ Co-Authored-By: Claude <noreply@anthropic.com> ❌
- **API Debug Endpoints**: `/debug/movie/{imdb_id}` for troubleshooting specific movies
- **IMDb ID Detection**: Comprehensive logging for directory/filename/NFO parsing
- **Three-Tier Logging**: Shows which optimization tier is used for each movie
- **Failed Movies Log**: Dedicated `logs/failed_movies.log` for movies with no_valid_date_source
### 🎯 PERFORMANCE TESTING SCENARIOS
- **Cold Database**: Test full processing with empty database (Tier 3 for all content)
@@ -252,6 +253,7 @@ Co-Authored-By: Claude <noreply@anthropic.com> ❌
4. **TMDB FALLBACK TESTING**: Test movies with TMDB IDs but no IMDb IDs
5. **MONITOR**: Database size should remain appropriate with new optimizations
6. **BENCHMARK**: Compare scan times before/after optimization (should see 90%+ improvement)
7. **DEBUG LOG**: Check `logs/failed_movies.log` for movies that couldn't get valid dates
---
**CONFIDENTIAL**: This file contains sensitive development information and remains on private Gitea only.
+26
View File
@@ -1281,6 +1281,10 @@ class MovieProcessor:
return self._get_file_mtime_date(movie_path)
else:
_log("INFO", f"No valid dates found for {imdb_id} and file date fallback disabled - skipping NFO creation")
# Log to failed movies debug file for troubleshooting
self._log_failed_movie(movie_path, imdb_id, "No import date, no release date, file date fallback disabled")
return None, "no_valid_date_source", None
def _get_digital_release_date(self, imdb_id: str) -> Tuple[Optional[str], str]:
@@ -1334,6 +1338,28 @@ class MovieProcessor:
_log("ERROR", f"Error reading Radarr NFO file: {e}")
return None
def _log_failed_movie(self, movie_path: Path, imdb_id: str, reason: str, available_countries: List[str] = None):
"""Log movies that failed to get valid dates to a debug file"""
try:
log_dir = Path("logs")
log_dir.mkdir(exist_ok=True)
failed_log_path = log_dir / "failed_movies.log"
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
log_entry = f"[{timestamp}] {movie_path.name} | IMDb: {imdb_id} | Reason: {reason}"
if available_countries:
log_entry += f" | Available Countries: {', '.join(available_countries)}"
log_entry += "\n"
with open(failed_log_path, "a", encoding="utf-8") as f:
f.write(log_entry)
_log("INFO", f"📝 Logged failed movie to {failed_log_path}: {movie_path.name}")
except Exception as e:
_log("ERROR", f"Failed to write to failed movies log: {e}")
def _get_file_mtime_date(self, movie_path: Path) -> Tuple[str, str, Optional[str]]:
"""Get date from file modification time as last resort"""
video_exts = (".mkv", ".mp4", ".avi", ".mov", ".m4v")