imdb: missing imdge improvments

This commit is contained in:
2025-10-26 15:48:26 -04:00
parent 10a9677804
commit 0b9f450b1d
6 changed files with 472 additions and 5 deletions
+99 -5
View File
@@ -844,9 +844,25 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
for item in scan_path.iterdir():
if (item.is_dir() and
not item.name.lower().startswith('season') and
not re.match(r'^season\s+\d+$', item.name, re.IGNORECASE) and
nfo_manager.parse_imdb_from_path(item)):
tv_series_list.append(item)
not re.match(r'^season\s+\d+$', item.name, re.IGNORECASE)):
# Check for IMDb ID
imdb_id = nfo_manager.parse_imdb_from_path(item)
if imdb_id:
tv_series_list.append(item)
else:
# Log missing IMDb ID for TV series
try:
db.add_missing_imdb(
file_path=str(item),
media_type="tv",
folder_name=item.name,
filename=None,
notes=f"TV series directory without IMDb ID detected during scan"
)
print(f"⚠️ Missing IMDb ID: TV series {item.name} - logged for manual review")
except Exception as e:
print(f"❌ Failed to log missing IMDb for TV series {item.name}: {e}")
tv_series_count = len(tv_series_list)
update_scan_status("tv", tv_series_total=tv_series_count)
@@ -894,8 +910,24 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
# Count total movies first for progress tracking
movie_list = []
for item in scan_path.iterdir():
if item.is_dir() and nfo_manager.find_movie_imdb_id(item):
movie_list.append(item)
if item.is_dir():
# Check for IMDb ID
imdb_id = nfo_manager.find_movie_imdb_id(item)
if imdb_id:
movie_list.append(item)
else:
# Log missing IMDb ID for movie
try:
db.add_missing_imdb(
file_path=str(item),
media_type="movie",
folder_name=item.name,
filename=None,
notes=f"Movie directory without IMDb ID detected during scan"
)
print(f"⚠️ Missing IMDb ID: Movie {item.name} - logged for manual review")
except Exception as e:
print(f"❌ Failed to log missing IMDb for movie {item.name}: {e}")
movie_total_count = len(movie_list)
update_scan_status(movies_total=movie_total_count)
@@ -2967,6 +2999,68 @@ def register_routes(app, dependencies: dict):
async def _nfo_repair_fix():
return await nfo_repair_fix()
@app.get("/admin/missing-imdb")
async def get_missing_imdb():
"""Get items missing IMDb IDs for manual review"""
config = dependencies.get("config")
db = dependencies.get("db")
if not config or not db:
raise HTTPException(status_code=500, detail="Dependencies not available")
print("📋 Retrieving missing IMDb items from core container")
try:
# Get missing items by type
missing_tv = db.get_missing_imdb_items(media_type="tv", resolved=False)
missing_movies = db.get_missing_imdb_items(media_type="movie", resolved=False)
# Format for web interface
missing_items = []
for item in missing_tv:
missing_items.append({
"id": item["id"],
"type": "TV Series",
"folder_name": item["folder_name"],
"file_path": item["file_path"],
"discovered_at": item["discovered_at"].isoformat() if item["discovered_at"] else None,
"last_checked": item["last_checked"].isoformat() if item["last_checked"] else None,
"check_count": item["check_count"],
"notes": item["notes"]
})
for item in missing_movies:
missing_items.append({
"id": item["id"],
"type": "Movie",
"folder_name": item["folder_name"],
"file_path": item["file_path"],
"discovered_at": item["discovered_at"].isoformat() if item["discovered_at"] else None,
"last_checked": item["last_checked"].isoformat() if item["last_checked"] else None,
"check_count": item["check_count"],
"notes": item["notes"]
})
print(f"✅ Found {len(missing_tv)} TV series and {len(missing_movies)} movies missing IMDb IDs")
return {
"status": "success",
"missing_items": missing_items,
"summary": {
"total_missing": len(missing_items),
"tv_series": len(missing_tv),
"movies": len(missing_movies)
}
}
except Exception as e:
print(f"❌ Error retrieving missing IMDb items: {e}")
return {
"status": "error",
"message": f"Failed to retrieve missing IMDb items: {str(e)}"
}
# ---------------------------
# Core API - No Web Interface
# ---------------------------