Use high-res images and return all photos in GeoJSON

- Use maxSizeUrl instead of url for photo URLs (highest available
  resolution from Rightmove)
- Remove 5-photo cap in GeoJSON export — return all available photos
- Apply same fix to both streaming and model-based export paths,
  and to the listing detail API endpoint
This commit is contained in:
Viktor Barzin 2026-02-22 00:54:58 +00:00
parent e2c22f025f
commit d50d1c07f6
No known key found for this signature in database
GPG key ID: 0EB088298288D958
2 changed files with 14 additions and 6 deletions

View file

@ -53,14 +53,18 @@ def convert_row_to_geojson(row: dict[str, Any], listing_type: str = "RENT") -> d
else:
last_seen_str = str(last_seen_val)
# Extract first 5 photo URLs from additional_info
# Extract photo URLs from additional_info (prefer high-res maxSizeUrl)
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', [])
photos = [img['url'] for img in images[:5] if isinstance(img, dict) and 'url' in img]
photos = [
img.get('maxSizeUrl') or img['url']
for img in images
if isinstance(img, dict) and ('maxSizeUrl' in img or 'url' in img)
]
if not photos and row.get('photo_thumbnail'):
photos = [row['photo_thumbnail']]
@ -110,9 +114,13 @@ def convert_to_geojson_feature(listing: RentListing | BuyListing) -> dict[str, A
property_info = listing.additional_info.get("property", {}) if listing.additional_info else {}
listing_type = "RENT" if isinstance(listing, RentListing) else "BUY"
# Extract first 5 photo URLs
# Extract photo URLs (prefer high-res maxSizeUrl)
images = property_info.get('images', [])
photos = [img['url'] for img in images[:5] if isinstance(img, dict) and 'url' in img]
photos = [
img.get('maxSizeUrl') or img['url']
for img in images
if isinstance(img, dict) and ('maxSizeUrl' in img or 'url' in img)
]
if not photos and listing.photo_thumbnail:
photos = [listing.photo_thumbnail]