diff --git a/if_curator/image_processing.py b/if_curator/image_processing.py index b422798..6c85895 100644 --- a/if_curator/image_processing.py +++ b/if_curator/image_processing.py @@ -74,10 +74,11 @@ def process_face_mode( # Find face metadata for this person face_info = None - for p in asset.get("people", []): + people_list = asset.get("people") or [] + for p in people_list: if p is None: continue - if p["id"] == person["id"] and (faces := p.get("faces")): + if p.get("id") == person["id"] and (faces := p.get("faces")): face_info = faces[0] break diff --git a/if_curator/immich_api.py b/if_curator/immich_api.py index c49a7cd..8cc9756 100644 --- a/if_curator/immich_api.py +++ b/if_curator/immich_api.py @@ -117,7 +117,10 @@ def fetch_face_data(asset_id: str, person_id: str | None = None) -> FaceData | N # Match the target person if specified face = None if person_id: - face = next((f for f in faces if f.get("person", {}).get("id") == person_id), None) + face = next( + (f for f in faces if (f.get("person") or {}).get("id") == person_id), + None, + ) if face is None: face = faces[0] # Fall back to first/largest face @@ -145,7 +148,7 @@ def fetch_face_data(asset_id: str, person_id: str | None = None) -> FaceData | N except requests.RequestException as e: logger.debug(f"Failed to fetch face data for {asset_id}: {e}") return None - except (KeyError, TypeError, ValueError) as e: + except (AttributeError, KeyError, TypeError, ValueError) as e: logger.debug(f"Failed to parse face data for {asset_id}: {e}") return None