feat: Add dedicated failed movies debug log
- 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:
+26
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user