Skip to content

Commit 65e8896

Browse files
committed
Add photos_count field to extract total number of place photos
Extracts the total photo count from darray[37][1] in the Google Maps data structure. This provides the number of photos available for each place (e.g., "2614" for a restaurant with thousands of photos). Changes: - Add PhotosCount field to Entry struct - Extract value from darray[37][1] - Add photos_count to CSV headers and output - Update test expectations
1 parent 95a1cc2 commit 65e8896

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

gmaps/entry.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ type Entry struct {
8484
Timezone string `json:"timezone"`
8585
PriceRange string `json:"price_range"`
8686
DataID string `json:"data_id"`
87+
PhotosCount int `json:"photos_count"`
8788
Images []Image `json:"images"`
8889
Reservations []LinkSource `json:"reservations"`
8990
OrderOnline []LinkSource `json:"order_online"`
@@ -180,6 +181,7 @@ func (e *Entry) CsvHeaders() []string {
180181
"timezone",
181182
"price_range",
182183
"data_id",
184+
"photos_count",
183185
"images",
184186
"reservations",
185187
"order_online",
@@ -218,6 +220,7 @@ func (e *Entry) CsvRow() []string {
218220
e.Timezone,
219221
e.PriceRange,
220222
e.DataID,
223+
stringify(e.PhotosCount),
221224
stringify(e.Images),
222225
stringify(e.Reservations),
223226
stringify(e.OrderOnline),
@@ -341,6 +344,7 @@ func EntryFromJSON(raw []byte, reviewCountOnly ...bool) (entry Entry, err error)
341344
entry.Timezone = getNthElementAndCast[string](darray, 30)
342345
entry.PriceRange = getNthElementAndCast[string](darray, 4, 2)
343346
entry.DataID = getNthElementAndCast[string](darray, 10)
347+
entry.PhotosCount = int(getNthElementAndCast[float64](darray, 37, 1))
344348

345349
items := getLinkSource(getLinkSourceParams{
346350
arr: getNthElementAndCast[[]any](darray, 171, 0),

gmaps/entry_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func Test_EntryFromJSON(t *testing.T) {
5555
Timezone: "Asia/Nicosia",
5656
PriceRange: "€€",
5757
DataID: "0x14e732fd76f0d90d:0xe5415928d6702b47",
58+
PhotosCount: 411,
5859
Images: []gmaps.Image{
5960
{
6061
Title: "All",

0 commit comments

Comments
 (0)