forked from amencarini/songkick
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.go
More file actions
75 lines (66 loc) · 1.82 KB
/
Copy pathevent.go
File metadata and controls
75 lines (66 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package songkick
import "strconv"
type Event struct {
Name string `json:"displayName"`
Type string `json:"type"`
Popularity float64 `json:"popularity"`
Status string `json:"status"`
Agerestriction interface{} `json:"ageRestriction"`
Start struct {
Time string `json:"time"`
Datetime string `json:"datetime"`
Date string `json:"date"`
} `json:"start"`
Performances []struct {
Billingindex int `json:"billingIndex"`
Name string `json:"displayName"`
Artist Artist `json:"artist"`
Billing string `json:"billing"`
ID uint `json:"id"`
} `json:"performance"`
Location struct {
City string `json:"city"`
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
} `json:"location"`
Venue struct {
Displayname string `json:"displayName"`
Metroarea struct {
Displayname string `json:"displayName"`
URI string `json:"uri"`
ID int `json:"id"`
Country struct {
Displayname string `json:"displayName"`
} `json:"country"`
} `json:"metroArea"`
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
URI string `json:"uri"`
ID int `json:"id"`
} `json:"venue"`
URI string `json:"uri"`
ID uint `json:"id"`
}
func (c *Client) GetEvents(minDate, maxDate string, locationId int) ([]Event, error) {
params := map[string]string{
"min_date": minDate,
"max_date": maxDate,
"location": "sk:" + strconv.Itoa(locationId),
"page": "1",
}
var events []Event
page := 1
for {
result, err := c.doSearch("events.json", params)
if err != nil {
return events, err
}
events = append(events, result.Resultspage.Results.Events...)
if len(events) == result.Resultspage.Totalentries {
break
}
page++
params["page"] = strconv.Itoa(page)
}
return events, nil
}