-
Notifications
You must be signed in to change notification settings - Fork 19
/
catalog_charts_test.go
242 lines (232 loc) · 9.91 KB
/
catalog_charts_test.go
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
package applemusic
import (
"context"
"encoding/json"
"net/http"
"reflect"
"testing"
)
func TestCatalogService_GetAllCharts(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1/catalog/us/charts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{
"types": "songs,albums",
"genre": "20",
"limit": "1",
})
w.WriteHeader(http.StatusOK)
_, _ = w.Write(chartsJSON)
})
opt := &ChartsOptions{
Types: "songs,albums",
Genre: "20",
Limit: 1,
}
got, _, err := client.Catalog.GetAllCharts(context.Background(), "us", opt)
if err != nil {
t.Errorf("Catalog.GetAllCharts returned error: %v", err)
}
if want := charts; !reflect.DeepEqual(got, want) {
t.Errorf("Catalog.GetAllCharts = %+v, want %+v", got, want)
b, _ := json.Marshal(want)
t.Log("json:", string(b))
}
}
var chartsJSON = []byte(`{
"results": {
"albums": [
{
"name": "Most Played Albums on Apple Music",
"chart": "most-played",
"href": "/v1/catalog/us/charts?types=albums&chart=most-played&genre=20&limit=1",
"next": "/v1/catalog/us/charts?types=albums&chart=most-played&genre=20&offset=1",
"data": [
{
"id": "1256684768",
"type": "albums",
"href": "/v1/catalog/us/albums/1256684768",
"attributes": {
"artwork": {
"width": 1800,
"height": 1800,
"url": "https://is5-ssl.mzstatic.com/image/thumb/Music128/v4/fd/4b/c6/fd4bc65d-e552-a1b0-1a62-49d6fd4e77ae/source/{w}x{h}bb.jpg",
"bgColor": "eae7de",
"textColor1": "050c13",
"textColor2": "1d3336",
"textColor3": "33383b",
"textColor4": "465758"
},
"artistName": "Lana Del Rey",
"isSingle": false,
"url": "https://itunes.apple.com/us/album/lust-for-life/id1256684768",
"isComplete": true,
"genreNames": [
"Alternative",
"Music",
"Rock"
],
"trackCount": 16,
"releaseDate": "2017-07-21",
"name": "Lust for Life",
"copyright": "℗ 2017 Lana Del Rey under exclusive licence to Polydor Ltd. (UK). Under exclusive licence to Interscope Records in the USA",
"playParams": {
"id": "1256684768",
"kind": "album"
},
"editorialNotes": {
"standard": "For the most part, Lana Del Rey’s fifth album is quintessentially her: gloomy, glamorous, and smitten with California. But a newfound lightness might surprise longtime fans. Each song on <i>Lust</i> feels like a postcard from a dream: She fantasizes about 1969 (“Coachella - Woodstock In My Mind”), outruns paparazzi on the Pacific Coast Highway (“13 Beaches”), and dances on the H of the Hollywood sign (“Lust for Life” feat. The Weeknd). She even duets with Stevie Nicks, the queen of bittersweet rock. On “Get Free,” she makes a vow to shift her mindset: \"Now I do, I want to move/Out of the black, into the blue.”",
"short": "Back in all her gloomy glamour, with Stevie Nicks and A$AP Rocky."
},
"contentRating": "explicit"
}
}
]
}
],
"songs": [
{
"name": "Most Played Songs on Apple Music",
"chart": "most-played",
"href": "/v1/catalog/us/charts?types=songs&chart=most-played&genre=20&limit=1",
"next": "/v1/catalog/us/charts?types=songs&chart=most-played&genre=20&offset=1",
"data": [
{
"id": "1233502267",
"type": "songs",
"href": "/v1/catalog/us/songs/1233502267",
"attributes": {
"artwork": {
"width": 1800,
"height": 1800,
"url": "https://is1-ssl.mzstatic.com/image/thumb/Music117/v4/2c/6b/cc/2c6bcc08-8a7a-dd89-d344-4e649f2a1bf8/source/{w}x{h}bb.jpg",
"bgColor": "0d1718",
"textColor1": "f6f9fe",
"textColor2": "f6b32b",
"textColor3": "c7cbd0",
"textColor4": "c89327"
},
"artistName": "Imagine Dragons",
"url": "https://itunes.apple.com/us/album/believer/id1233502263?i=1233502267",
"discNumber": 1,
"genreNames": [
"Alternative",
"Music"
],
"durationInMillis": 204345,
"releaseDate": "2017-02-01",
"name": "Believer",
"playParams": {
"id": "1233502267",
"kind": "song"
},
"trackNumber": 3,
"composerName": "Dan Reynolds, Wayne Sermon, Ben McKee, Daniel Platzman, Robin Fredriksson, Mattias Larsson & Justin Drew Tranter"
}
}
]
}
]
}
}`)
var charts = &Charts{
Results: ChartResults{
Albums: &[]ChartAlbums{
{
Name: "Most Played Albums on Apple Music",
Chart: "most-played",
Albums: Albums{
Href: "/v1/catalog/us/charts?types=albums&chart=most-played&genre=20&limit=1",
Next: "/v1/catalog/us/charts?types=albums&chart=most-played&genre=20&offset=1",
Data: []Album{
{
Id: "1256684768",
Type: "albums",
Href: "/v1/catalog/us/albums/1256684768",
Attributes: AlbumAttributes{
Artwork: Artwork{
Width: 1800,
Height: 1800,
URL: "https://is5-ssl.mzstatic.com/image/thumb/Music128/v4/fd/4b/c6/fd4bc65d-e552-a1b0-1a62-49d6fd4e77ae/source/{w}x{h}bb.jpg",
BgColor: "eae7de",
TextColor1: "050c13",
TextColor2: "1d3336",
TextColor3: "33383b",
TextColor4: "465758",
},
ArtistName: "Lana Del Rey",
IsSingle: false,
URL: "https://itunes.apple.com/us/album/lust-for-life/id1256684768",
IsComplete: true,
GenreNames: []string{
"Alternative",
"Music",
"Rock",
},
TrackCount: 16,
ReleaseDate: "2017-07-21",
Name: "Lust for Life",
Copyright: "℗ 2017 Lana Del Rey under exclusive licence to Polydor Ltd. (UK). Under exclusive licence to Interscope Records in the USA",
PlayParams: &PlayParameters{
Id: "1256684768",
Kind: "album",
},
EditorialNotes: &EditorialNotes{
Standard: "For the most part, Lana Del Rey’s fifth album is quintessentially her: gloomy, glamorous, and smitten with California. But a newfound lightness might surprise longtime fans. Each song on <i>Lust</i> feels like a postcard from a dream: She fantasizes about 1969 (“Coachella - Woodstock In My Mind”), outruns paparazzi on the Pacific Coast Highway (“13 Beaches”), and dances on the H of the Hollywood sign (“Lust for Life” feat. The Weeknd). She even duets with Stevie Nicks, the queen of bittersweet rock. On “Get Free,” she makes a vow to shift her mindset: \"Now I do, I want to move/Out of the black, into the blue.”",
Short: "Back in all her gloomy glamour, with Stevie Nicks and A$AP Rocky.",
},
ContentRating: "explicit",
},
},
},
},
},
},
Songs: &[]ChartSongs{
{
Name: "Most Played Songs on Apple Music",
Chart: "most-played",
Songs: Songs{
Href: "/v1/catalog/us/charts?types=songs&chart=most-played&genre=20&limit=1",
Next: "/v1/catalog/us/charts?types=songs&chart=most-played&genre=20&offset=1",
Data: []Song{
{
Id: "1233502267",
Type: "songs",
Href: "/v1/catalog/us/songs/1233502267",
Attributes: SongAttributes{
Artwork: Artwork{
Width: 1800,
Height: 1800,
URL: "https://is1-ssl.mzstatic.com/image/thumb/Music117/v4/2c/6b/cc/2c6bcc08-8a7a-dd89-d344-4e649f2a1bf8/source/{w}x{h}bb.jpg",
BgColor: "0d1718",
TextColor1: "f6f9fe",
TextColor2: "f6b32b",
TextColor3: "c7cbd0",
TextColor4: "c89327",
},
ArtistName: "Imagine Dragons",
URL: "https://itunes.apple.com/us/album/believer/id1233502263?i=1233502267",
DiscNumber: 1,
GenreNames: []string{
"Alternative",
"Music",
},
DurationInMillis: 204345,
ReleaseDate: "2017-02-01",
Name: "Believer",
PlayParams: &PlayParameters{
Id: "1233502267",
Kind: "song",
},
TrackNumber: 3,
ComposerName: "Dan Reynolds, Wayne Sermon, Ben McKee, Daniel Platzman, Robin Fredriksson, Mattias Larsson & Justin Drew Tranter",
},
},
},
},
},
},
},
}