-
Notifications
You must be signed in to change notification settings - Fork 19
/
me_library_songs.go
58 lines (48 loc) · 1.85 KB
/
me_library_songs.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
package applemusic
import "context"
// LibrarySongAttributes represents the attributes of library song object.
type LibrarySongAttributes struct {
AlbumName string `json:"albumName"`
ArtistName string `json:"artistName"`
Artwork Artwork `json:"artwork"`
ContentRating string `json:"contentRating,omitempty"`
DiscNumber int `json:"discNumber"`
DurationInMillis int64 `json:"durationInMillis,omitempty"`
Name string `json:"name"`
PlayParams PlayParameters `json:"playParams,omitempty"`
TrackNumber int `json:"trackNumber"`
}
// LibrarySong represents a Resource object that represents a library song.
type LibrarySong struct {
Id string `json:"id"`
Type string `json:"type"`
Href string `json:"href,omitempty"`
Attributes LibrarySongAttributes `json:"attributes,omitempty"`
}
// LibrarySongs represents a list of library songs.
type LibrarySongs struct {
Data []LibrarySong `json:"data"`
Href string `json:"href,omitempty"`
Next string `json:"next,omitempty"`
}
func (s *MeService) getLibrarySongs(ctx context.Context, u string, opt interface{}) (*LibrarySongs, *Response, error) {
u, err := addOptions(u, opt)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
librarySongs := &LibrarySongs{}
resp, err := s.client.Do(ctx, req, librarySongs)
if err != nil {
return nil, resp, err
}
return librarySongs, resp, nil
}
// GetAllLibrarySongs fetches all the library songs in alphabetical order.
func (s *MeService) GetAllLibrarySongs(ctx context.Context, opt *PageOptions) (*LibrarySongs, *Response, error) {
u := "v1/me/library/songs"
return s.getLibrarySongs(ctx, u, opt)
}