-
Notifications
You must be signed in to change notification settings - Fork 3
/
artist.go
123 lines (83 loc) · 2.72 KB
/
artist.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
package gomusixmatch
import (
"context"
mxmParams "github.com/milindmadhukar/go-musixmatch/params"
)
/*
Get the artist data from Musixmatch's database.
Parameters:
ArtistID - Musixmatch artist id
ArtistMbID - Musicbrainz artist id
*/
func (client *Client) GetArtist(ctx context.Context, params ...mxmParams.Param) (*Artist, error) {
var artistData artist
err := client.get(ctx, "artist.get", &artistData, params...)
if err != nil {
return nil, err
}
return &artistData.ArtistData, nil
}
/*
Search for artists in Musixmatch's database.
Parameters:
QueryArtist - The song artist
ArtistID - When set, filter by this artist id
ArtistMbID - When set, filter by this artist musicbrainz id
Page - Define the page number for paginated results
PageSize - Define the page size for paginated results. Range is 1 to 100.
*/
func (client *Client) SearchArtist(ctx context.Context, params ...mxmParams.Param) ([]*Artist, error) {
var artistsData artistList
err := client.get(ctx, "artist.search", &artistsData, params...)
if err != nil {
return nil, err
}
var artists []*Artist
artistList := artistsData.ArtistList
for i := 0; i < len(artistList); i++ {
artists = append(artists, &artistList[i].ArtistData)
}
return artists, nil
}
/*
Get the album discography of an artist
Parameters:
ArtistID - Musixmatch artist id
ArtistMbID - Musicbrainz artist id
GroupByAlbumName - Group by Album Name
SortByReleaseDate - Sort by release date (asc|desc)
Page - Define the page number for paginated results
PageSize - Define the page size for paginated results. Range is 1 to 100.
*/
func (client *Client) GetArtistAlbums(ctx context.Context, params ...mxmParams.Param) ([]*Album, error) {
var albumsData albumList
err := client.get(ctx, "artist.albums.get", &albumsData, params...)
if err != nil {
return nil, err
}
var albums []*Album
for i := 0; i < len(albumsData.AlbumList); i++ {
albums = append(albums, &albumsData.AlbumList[i].AlbumData)
}
return albums, nil
}
/*
Get a list of artists somehow related to a given one.
Parameters:
ArtistID - Musixmatch artist id
ArtistMbID - Musicbrainz artist id
Page - Define the page number for paginated results
PageSize - Define the page size for paginated results. Range is 1 to 100.
*/
func (client *Client) GetRelatedArtists(ctx context.Context, params ...mxmParams.Param) ([]*Artist, error) {
var artistData artistList
err := client.get(ctx, "artist.related.get", &artistData, params...)
if err != nil {
return nil, err
}
var artists []*Artist
for _, artist := range artistData.ArtistList {
artists = append(artists, &artist.ArtistData)
}
return artists, nil
}