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.
This commit is contained in:
Viktor Barzin 2026-02-22 01:21:50 +00:00
parent d50d1c07f6
commit a2c1f81644
No known key found for this signature in database
GPG key ID: 0EB088298288D958
2 changed files with 7 additions and 3 deletions

View file

@ -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:

View file

@ -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