-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathchart.go
71 lines (49 loc) · 1.7 KB
/
chart.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
package gomusixmatch
import (
"context"
mxmParams "github.com/milindmadhukar/go-musixmatch/params"
)
/*
Gets the API response of the top artists of a given country.
Parameters:
Country - A valid country code.
Page - Define the page number for paginated results.
PageSize - Define the page size for paginated results. Range is 1 to 100.
*/
func (client *Client) GetTopArtists(ctx context.Context, params ...mxmParams.Param) ([]*Artist, error) {
var artistsData artistList
err := client.get(ctx, "chart.artists.get", &artistsData, params...)
if err != nil {
return nil, err
}
var artists []*Artist
for _, artist := range artistsData.ArtistList {
artists = append(artists, &artist.ArtistData)
}
return artists, nil
}
/*
Gets the API response of the top songs of a given country.
Parameters:
Country - A valid 2 letters country code. Set XW as worldwide
Page - Define the page number for paginated results.
PageSize - Define the page size for paginated results. Range is 1 to 100.
ChartName - Select among available charts:
top : editorial chart.
hot : Most viewed lyrics in the last 2 hours.
mxmweekly : Most viewed lyrics in the last 7 days.
mxmweekly_new : Most viewed lyrics in the last 7 days limited to new releases only.
HasLyrics - When set, filters only contents with lyrics.
*/
func (client *Client) GetTopTracks(ctx context.Context, params ...mxmParams.Param) ([]*Track, error) {
var tracksData trackList
err := client.get(ctx, "chart.tracks.get", &tracksData, params...)
if err != nil {
return nil, err
}
var tracks []*Track
for _, track := range tracksData.TrackList {
tracks = append(tracks, &track.TrackData)
}
return tracks, nil
}