From a2c1f816441b564f4755f20ca82bdc129d8b05c7 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Sun, 22 Feb 2026 01:21:50 +0000 Subject: [PATCH] Fix photo extraction: look for both 'photos' and 'images' keys Rightmove API stores photos under the 'photos' key in the response, but the GeoJSON export and detail API were only checking 'images'. This key mismatch caused all listings to fall back to the single photo_thumbnail. Now checks both keys with fallback. --- api/app.py | 3 ++- ui_exporter.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/api/app.py b/api/app.py index 7ea0389..46534d1 100644 --- a/api/app.py +++ b/api/app.py @@ -605,7 +605,8 @@ async def get_listing_detail( description = text_info.get("description") if isinstance(text_info, dict) else None # Extract photos (prefer high-res maxSizeUrl) - photos_raw = property_info.get("images", []) + # Rightmove API stores photos under "photos" key, but some code paths used "images" + photos_raw = property_info.get("images", []) or property_info.get("photos", []) photos: list[dict] = [] if isinstance(photos_raw, list): for img in photos_raw: diff --git a/ui_exporter.py b/ui_exporter.py index cb7709c..179fba5 100644 --- a/ui_exporter.py +++ b/ui_exporter.py @@ -54,12 +54,14 @@ def convert_row_to_geojson(row: dict[str, Any], listing_type: str = "RENT") -> d last_seen_str = str(last_seen_val) # Extract photo URLs from additional_info (prefer high-res maxSizeUrl) + # Rightmove API stores photos under "photos" key, but some code paths used "images" photos: list[str] = [] additional_info = row.get('additional_info') if additional_info: if isinstance(additional_info, str): additional_info = json.loads(additional_info) - images = additional_info.get('property', {}).get('images', []) + prop = additional_info.get('property', {}) + images = prop.get('images', []) or prop.get('photos', []) photos = [ img.get('maxSizeUrl') or img['url'] for img in images @@ -115,7 +117,8 @@ def convert_to_geojson_feature(listing: RentListing | BuyListing) -> dict[str, A listing_type = "RENT" if isinstance(listing, RentListing) else "BUY" # Extract photo URLs (prefer high-res maxSizeUrl) - images = property_info.get('images', []) + # Rightmove API stores photos under "photos" key, but some code paths used "images" + images = property_info.get('images', []) or property_info.get('photos', []) photos = [ img.get('maxSizeUrl') or img['url'] for img in images