Skip to content

Commit dd337eb

Browse files
authored
fix(reviews): return direct photo URL instead of imagery/report link (#260)
The review image extraction was navigating to el[2][2][0][1][21][7] (and a fallback at [2][2][0][1][7]), which points at Google's imagery/report endpoint — the 'report this photo' moderation link, not the hosted image. As a result, user_reviews[].Images contained URLs like: www.google.com/local/imagery/report/?cb_client=maps_sv.tactile&image_key=... that can't be rendered. The actual image list is at el[2][2], where each image's direct lh3.googleusercontent.com URL lives at [1][6][0]. This commit updates parseReviews to walk that path, so Images now contains renderable URLs such as: https://lh3.googleusercontent.com/geougc-cs/AMG9lEQ...=w1200-h900-p Fixes #240.
1 parent 1af177d commit dd337eb

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

gmaps/entry.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -525,16 +525,15 @@ func parseReviews(reviewsI []any) []Review {
525525
continue
526526
}
527527

528-
// Try multiple paths for images
529-
optsI := getNthElementAndCast[[]any](el, 2, 2, 0, 1, 21, 7)
530-
if len(optsI) == 0 {
531-
optsI = getNthElementAndCast[[]any](el, 2, 2, 0, 1, 7)
532-
}
533-
534-
for j := range optsI {
535-
val := getNthElementAndCast[string](optsI, j)
536-
if val != "" && len(val) > 2 {
537-
review.Images = append(review.Images, val[2:])
528+
// Extract user-contributed photo URLs for this review.
529+
// Structure: el[2][2] is the image list; each image's direct lh3 URL lives at [1][6][0].
530+
// The previous paths (e.g. [2][2][0][1][21][7]) landed on the imagery/report
531+
// "report this photo" URL, not the actual hosted image. See issue #240.
532+
imgs := getNthElementAndCast[[]any](el, 2, 2)
533+
for j := range imgs {
534+
url := getNthElementAndCast[string](imgs, j, 1, 6, 0)
535+
if url != "" {
536+
review.Images = append(review.Images, url)
538537
}
539538
}
540539

0 commit comments

Comments
 (0)