-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaylist.go
175 lines (169 loc) · 5.21 KB
/
playlist.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
package main
import (
"context"
"fmt"
)
type Playlist struct {
Collaborative bool `json:"collaborative"`
Description string `json:"description"`
ExternalUrls struct {
Spotify string `json:"spotify"`
} `json:"external_urls"`
Followers struct {
Href string `json:"href"`
Total int `json:"total"`
} `json:"followers"`
Href string `json:"href"`
ID string `json:"id"`
Images []struct {
URL string `json:"url"`
Height int `json:"height"`
Width int `json:"width"`
} `json:"images"`
Name string `json:"name"`
Owner struct {
ExternalUrls struct {
Spotify string `json:"spotify"`
} `json:"external_urls"`
Followers struct {
Href string `json:"href"`
Total int `json:"total"`
} `json:"followers"`
Href string `json:"href"`
ID string `json:"id"`
Type string `json:"type"`
URI string `json:"uri"`
DisplayName string `json:"display_name"`
} `json:"owner"`
Public bool `json:"public"`
SnapshotID string `json:"snapshot_id"`
Tracks struct {
Href string `json:"href"`
Limit int `json:"limit"`
Next string `json:"next"`
Offset int `json:"offset"`
Previous string `json:"previous"`
Total int `json:"total"`
Items []struct {
AddedAt string `json:"added_at"`
AddedBy struct {
ExternalUrls struct {
Spotify string `json:"spotify"`
} `json:"external_urls"`
Followers struct {
Href string `json:"href"`
Total int `json:"total"`
} `json:"followers"`
Href string `json:"href"`
ID string `json:"id"`
Type string `json:"type"`
URI string `json:"uri"`
} `json:"added_by"`
IsLocal bool `json:"is_local"`
Track struct {
Album struct {
AlbumType string `json:"album_type"`
TotalTracks int `json:"total_tracks"`
AvailableMarkets []string `json:"available_markets"`
ExternalUrls struct {
Spotify string `json:"spotify"`
} `json:"external_urls"`
Href string `json:"href"`
ID string `json:"id"`
Images []struct {
URL string `json:"url"`
Height int `json:"height"`
Width int `json:"width"`
} `json:"images"`
Name string `json:"name"`
ReleaseDate string `json:"release_date"`
ReleaseDatePrecision string `json:"release_date_precision"`
Restrictions struct {
Reason string `json:"reason"`
} `json:"restrictions"`
Type string `json:"type"`
URI string `json:"uri"`
Copyrights []struct {
Text string `json:"text"`
Type string `json:"type"`
} `json:"copyrights"`
ExternalIds struct {
Isrc string `json:"isrc"`
Ean string `json:"ean"`
Upc string `json:"upc"`
} `json:"external_ids"`
Genres []string `json:"genres"`
Label string `json:"label"`
Popularity int `json:"popularity"`
AlbumGroup string `json:"album_group"`
Artists []struct {
ExternalUrls struct {
Spotify string `json:"spotify"`
} `json:"external_urls"`
Href string `json:"href"`
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
URI string `json:"uri"`
} `json:"artists"`
} `json:"album"`
Artists []struct {
ExternalUrls struct {
Spotify string `json:"spotify"`
} `json:"external_urls"`
Followers struct {
Href string `json:"href"`
Total int `json:"total"`
} `json:"followers"`
Genres []string `json:"genres"`
Href string `json:"href"`
ID string `json:"id"`
Images []struct {
URL string `json:"url"`
Height int `json:"height"`
Width int `json:"width"`
} `json:"images"`
Name string `json:"name"`
Popularity int `json:"popularity"`
Type string `json:"type"`
URI string `json:"uri"`
} `json:"artists"`
AvailableMarkets []string `json:"available_markets"`
DiscNumber int `json:"disc_number"`
DurationMs int `json:"duration_ms"`
Explicit bool `json:"explicit"`
ExternalIds struct {
Isrc string `json:"isrc"`
Ean string `json:"ean"`
Upc string `json:"upc"`
} `json:"external_ids"`
ExternalUrls struct {
Spotify string `json:"spotify"`
} `json:"external_urls"`
Href string `json:"href"`
ID string `json:"id"`
IsPlayable bool `json:"is_playable"`
LinkedFrom struct {
} `json:"linked_from"`
Restrictions struct {
Reason string `json:"reason"`
} `json:"restrictions"`
Name string `json:"name"`
Popularity int `json:"popularity"`
PreviewURL string `json:"preview_url"`
TrackNumber int `json:"track_number"`
Type string `json:"type"`
URI string `json:"uri"`
IsLocal bool `json:"is_local"`
} `json:"track"`
} `json:"items"`
} `json:"tracks"`
Type string `json:"type"`
URI string `json:"uri"`
}
func (c *Client) GetPlaylist(ctx context.Context, id string) (*Playlist, error) {
spotifyURL := fmt.Sprintf("%splaylists/%s", c.baseURL, id)
var playlist Playlist
err := c.get(ctx, spotifyURL, &playlist)
return &playlist, err
}