Fix sparse request metadata hydration
This commit is contained in:
@@ -59,6 +59,22 @@ def _pick_first(value: Any) -> Optional[Dict[str, Any]]:
|
||||
return None
|
||||
|
||||
|
||||
def _apply_arr_identity(snapshot: Snapshot, arr_item: Any) -> None:
|
||||
"""Use the collector's authoritative identity when cached Seerr metadata is sparse."""
|
||||
if not isinstance(arr_item, dict):
|
||||
return
|
||||
if snapshot.title in {None, "", "Unknown"}:
|
||||
title = arr_item.get("title") or arr_item.get("seriesTitle")
|
||||
if isinstance(title, str) and title.strip():
|
||||
snapshot.title = title.strip()
|
||||
if not snapshot.year:
|
||||
year = arr_item.get("year")
|
||||
try:
|
||||
snapshot.year = int(year) if year else snapshot.year
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
|
||||
|
||||
def _normalize_media_title(value: Any) -> Optional[str]:
|
||||
if not isinstance(value, str):
|
||||
return None
|
||||
@@ -821,7 +837,7 @@ async def build_snapshot(request_id: str) -> Snapshot:
|
||||
poster_path = media.get("posterPath") or media.get("poster_path")
|
||||
backdrop_path = media.get("backdropPath") or media.get("backdrop_path")
|
||||
|
||||
if snapshot.title in {None, "", "Unknown"} and allow_remote:
|
||||
if snapshot.title in {None, "", "Unknown"} and jellyseerr.configured():
|
||||
tmdb_id = jelly_request.get("media", {}).get("tmdbId")
|
||||
if tmdb_id:
|
||||
details = await _get_seerr_media_details(jellyseerr, snapshot.request_type, int(tmdb_id))
|
||||
@@ -971,6 +987,7 @@ async def build_snapshot(request_id: str) -> Snapshot:
|
||||
if arr_state is None:
|
||||
arr_state = "unknown"
|
||||
|
||||
_apply_arr_identity(snapshot, arr_item)
|
||||
timeline.append(TimelineHop(service="Sonarr/Radarr", status=arr_state, details=arr_details))
|
||||
|
||||
prowlarr_state = "unknown"
|
||||
|
||||
Reference in New Issue
Block a user