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:
parent
e2c22f025f
commit
d50d1c07f6
2 changed files with 14 additions and 6 deletions
|
|
@ -604,14 +604,14 @@ async def get_listing_detail(
|
||||||
text_info = property_info.get("text", {})
|
text_info = property_info.get("text", {})
|
||||||
description = text_info.get("description") if isinstance(text_info, dict) else None
|
description = text_info.get("description") if isinstance(text_info, dict) else None
|
||||||
|
|
||||||
# Extract photos
|
# Extract photos (prefer high-res maxSizeUrl)
|
||||||
photos_raw = property_info.get("images", [])
|
photos_raw = property_info.get("images", [])
|
||||||
photos: list[dict] = []
|
photos: list[dict] = []
|
||||||
if isinstance(photos_raw, list):
|
if isinstance(photos_raw, list):
|
||||||
for img in photos_raw:
|
for img in photos_raw:
|
||||||
if isinstance(img, dict):
|
if isinstance(img, dict):
|
||||||
photos.append({
|
photos.append({
|
||||||
"url": img.get("url", ""),
|
"url": img.get("maxSizeUrl") or img.get("url", ""),
|
||||||
"caption": img.get("caption", ""),
|
"caption": img.get("caption", ""),
|
||||||
"type": img.get("type", ""),
|
"type": img.get("type", ""),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -53,14 +53,18 @@ def convert_row_to_geojson(row: dict[str, Any], listing_type: str = "RENT") -> d
|
||||||
else:
|
else:
|
||||||
last_seen_str = str(last_seen_val)
|
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] = []
|
photos: list[str] = []
|
||||||
additional_info = row.get('additional_info')
|
additional_info = row.get('additional_info')
|
||||||
if additional_info:
|
if additional_info:
|
||||||
if isinstance(additional_info, str):
|
if isinstance(additional_info, str):
|
||||||
additional_info = json.loads(additional_info)
|
additional_info = json.loads(additional_info)
|
||||||
images = additional_info.get('property', {}).get('images', [])
|
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'):
|
if not photos and row.get('photo_thumbnail'):
|
||||||
photos = [row['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 {}
|
property_info = listing.additional_info.get("property", {}) if listing.additional_info else {}
|
||||||
listing_type = "RENT" if isinstance(listing, RentListing) else "BUY"
|
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', [])
|
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:
|
if not photos and listing.photo_thumbnail:
|
||||||
photos = [listing.photo_thumbnail]
|
photos = [listing.photo_thumbnail]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue