updates for debug scan
This commit is contained in:
@@ -77,11 +77,13 @@ POST /webhook/sonarr – Sonarr events
|
||||
|
||||
POST /webhook/radarr – Radarr events
|
||||
|
||||
POST /manual/scan – Manual scan (TV + Movies)
|
||||
POST /manual/scan?scan_type=both – Manual scan (TV + Movies) [DEFAULT]
|
||||
|
||||
POST /manual/scan/tv – Manual scan TV only
|
||||
POST /manual/scan?scan_type=tv – Manual scan TV only
|
||||
|
||||
POST /manual/scan/movies – Manual scan Movies only
|
||||
POST /manual/scan?scan_type=movies – Manual scan Movies only
|
||||
|
||||
POST /manual/scan?path=/media/movies – Manual scan specific path
|
||||
|
||||
GET /health – Health check
|
||||
|
||||
@@ -89,6 +91,8 @@ GET /stats – Database stats
|
||||
|
||||
GET /batch/status – Current batch queue
|
||||
|
||||
GET /debug/movie/{imdb_id} – Debug movie import date detection
|
||||
|
||||
📖 Example Workflow
|
||||
You add The Blacklist in Sonarr.
|
||||
|
||||
@@ -100,7 +104,32 @@ NFOGuard updates the .nfo and mtime, but keeps the original import date.
|
||||
|
||||
Emby/Jellyfin/Plex see the file as unchanged in chronology.
|
||||
|
||||
Result: no more “old shows” showing up in “Recently Added.”
|
||||
Result: no more "old shows" showing up in "Recently Added."
|
||||
|
||||
🔍 Logging & Debugging
|
||||
# Enable verbose logging
|
||||
DEBUG=true
|
||||
|
||||
# Check container logs
|
||||
docker logs sonarr-nfo-cache
|
||||
|
||||
# Debug specific movie import detection
|
||||
curl http://localhost:8080/debug/movie/tt1674782
|
||||
|
||||
# Manual scan with verbose output
|
||||
curl -X POST "http://localhost:8080/manual/scan?scan_type=movies"
|
||||
|
||||
# File logs (inside container)
|
||||
/app/data/logs/nfoguard.log
|
||||
|
||||
⚙️ Environment Variables (v0.2.1+)
|
||||
Variable Default Description
|
||||
RADARR_ROOT_FOLDERS (required) What Radarr sees: /mnt/unionfs/Media/Movies/movies
|
||||
SONARR_ROOT_FOLDERS (required) What Sonarr sees: /mnt/unionfs/Media/TV/tv
|
||||
DOWNLOAD_PATH_INDICATORS (see example) Paths that indicate downloads vs existing files
|
||||
MOVIE_PRIORITY import_then_digital Strategy: import_then_digital or digital_then_import
|
||||
MOVIE_POLL_MODE always When to query APIs: always, if_missing, never
|
||||
MOVIE_DATE_UPDATE_MODE backfill_only Update behavior: backfill_only or overwrite
|
||||
|
||||
📜 License
|
||||
MIT License – do what you want, just don’t blame us if your timestamps go timey-wimey.
|
||||
+83
@@ -798,6 +798,84 @@ async def batch_status():
|
||||
"""Get batch queue status"""
|
||||
return batcher.get_status()
|
||||
|
||||
@app.get("/debug/movie/{imdb_id}")
|
||||
async def debug_movie_import_date(imdb_id: str):
|
||||
"""Debug endpoint to analyze movie import date detection"""
|
||||
try:
|
||||
if not imdb_id.startswith("tt"):
|
||||
imdb_id = f"tt{imdb_id}"
|
||||
|
||||
_log("INFO", f"=== DEBUG MOVIE IMPORT DATE: {imdb_id} ===")
|
||||
|
||||
if not (os.environ.get("RADARR_URL") and os.environ.get("RADARR_API_KEY")):
|
||||
return {
|
||||
"error": "Radarr not configured",
|
||||
"imdb_id": imdb_id,
|
||||
"radarr_configured": False
|
||||
}
|
||||
|
||||
# Create Radarr client
|
||||
from clients.radarr_client import RadarrClient
|
||||
radarr_client = RadarrClient(
|
||||
os.environ.get("RADARR_URL"),
|
||||
os.environ.get("RADARR_API_KEY")
|
||||
)
|
||||
|
||||
# Look up movie
|
||||
movie_obj = radarr_client.movie_by_imdb(imdb_id)
|
||||
if not movie_obj:
|
||||
return {
|
||||
"error": f"Movie not found in Radarr for IMDb ID {imdb_id}",
|
||||
"imdb_id": imdb_id,
|
||||
"radarr_configured": True,
|
||||
"movie_found": False
|
||||
}
|
||||
|
||||
movie_id = movie_obj.get("id")
|
||||
movie_title = movie_obj.get("title")
|
||||
|
||||
_log("INFO", f"Found movie: {movie_title} (Radarr ID: {movie_id})")
|
||||
|
||||
# Get import date with detailed logging
|
||||
import_date, source = radarr_client.get_movie_import_date(movie_id)
|
||||
|
||||
# Get movie files
|
||||
movie_files = radarr_client.movie_files(movie_id)
|
||||
file_info = []
|
||||
for f in movie_files:
|
||||
file_info.append({
|
||||
"id": f.get("id"),
|
||||
"relativePath": f.get("relativePath"),
|
||||
"dateAdded": f.get("dateAdded"),
|
||||
"quality": f.get("quality", {}).get("quality", {}).get("name", "Unknown")
|
||||
})
|
||||
|
||||
return {
|
||||
"imdb_id": imdb_id,
|
||||
"radarr_configured": True,
|
||||
"movie_found": True,
|
||||
"movie_title": movie_title,
|
||||
"movie_id": movie_id,
|
||||
"detected_import_date": import_date,
|
||||
"import_source": source,
|
||||
"movie_files": file_info,
|
||||
"debug_info": {
|
||||
"radarr_url": os.environ.get("RADARR_URL"),
|
||||
"movie_digital_release": movie_obj.get("digitalRelease"),
|
||||
"movie_in_cinemas": movie_obj.get("inCinemas"),
|
||||
"movie_physical_release": movie_obj.get("physicalRelease"),
|
||||
"movie_folder_path": movie_obj.get("folderPath")
|
||||
}
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
_log("ERROR", f"Debug endpoint error for {imdb_id}: {e}")
|
||||
return {
|
||||
"error": str(e),
|
||||
"imdb_id": imdb_id,
|
||||
"success": False
|
||||
}
|
||||
|
||||
@app.post("/manual/scan")
|
||||
async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = None, scan_type: str = "both"):
|
||||
"""Manual scan endpoint"""
|
||||
@@ -827,12 +905,17 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
_log("ERROR", f"Failed processing TV series {item}: {e}")
|
||||
|
||||
if scan_type in ["both", "movies"] and scan_path in config.movie_paths:
|
||||
_log("INFO", f"Scanning movies in: {scan_path}")
|
||||
movie_count = 0
|
||||
for item in scan_path.iterdir():
|
||||
if item.is_dir() and nfo_manager.parse_imdb_from_path(item):
|
||||
movie_count += 1
|
||||
_log("INFO", f"Processing movie: {item.name}")
|
||||
try:
|
||||
movie_processor.process_movie(item)
|
||||
except Exception as e:
|
||||
_log("ERROR", f"Failed processing movie {item}: {e}")
|
||||
_log("INFO", f"Completed movie scan: {movie_count} movies processed in {scan_path}")
|
||||
|
||||
background_tasks.add_task(run_scan)
|
||||
return {"status": "started", "message": f"Manual {scan_type} scan started"}
|
||||
|
||||
Reference in New Issue
Block a user