-
Notifications
You must be signed in to change notification settings - Fork 19
/
me_history_recently_played_tracks.go
64 lines (54 loc) · 2.58 KB
/
me_history_recently_played_tracks.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
package applemusic
import "context"
// HistoryRecentlyPlayedTrackAttributes represents the attributes of history recently played song.
type HistoryRecentlyPlayedTrackAttributes struct {
AlbumName string `json:"albumName"`
ArtistName string `json:"artistName"`
Artwork Artwork `json:"artwork"`
DiscNumber int `json:"discNumber"`
DurationInMillis int64 `json:"durationInMillis,omitempty"`
Name string `json:"name"`
PlayParams PlayParameters `json:"playParams,omitempty"`
TrackNumber int `json:"trackNumber"`
GenreNames []string `json:"genreNames"`
ReleaseDate string `json:"releaseDate"`
ISRC string `json:"isrc"`
URL string `json:"url"`
HasLyrics bool `json:"hasLyrics"`
IsAppleDigitalMaster bool `json:"isAppleDigitalMaster"`
Previews []Preview `json:"previews,omitempty"`
}
// HistoryRecentlyPlayedTrack represents a Resource object that represents a history recently played song.
type HistoryRecentlyPlayedTrack struct {
Id string `json:"id"`
Type string `json:"type"`
Href string `json:"href,omitempty"`
Attributes HistoryRecentlyPlayedTrackAttributes `json:"attributes,omitempty"`
}
// HistoryRecentlyPlayedTracks represents a list of history recently played songs.
type HistoryRecentlyPlayedTracks struct {
Data []HistoryRecentlyPlayedTrack `json:"data"`
Href string `json:"href,omitempty"`
Next string `json:"next,omitempty"`
}
func (s *MeService) getHistoryRecentlyPlayedTracks(ctx context.Context, u string, opt interface{}) (*HistoryRecentlyPlayedTracks, *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
}
historyRecentlyPlayedTracks := &HistoryRecentlyPlayedTracks{}
resp, err := s.client.Do(ctx, req, historyRecentlyPlayedTracks)
if err != nil {
return nil, resp, err
}
return historyRecentlyPlayedTracks, resp, nil
}
// GetHistoryRecentlyPlayedTracks fetches all history recently played songs.
func (s *MeService) GetHistoryRecentlyPlayedTracks(ctx context.Context, opt *PageOptions) (*HistoryRecentlyPlayedTracks, *Response, error) {
u := "v1/me/recent/played/tracks"
return s.getHistoryRecentlyPlayedTracks(ctx, u, opt)
}