-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathalbum.go
57 lines (39 loc) · 1.2 KB
/
album.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
package gomusixmatch
import (
"context"
mxmParams "github.com/milindmadhukar/go-musixmatch/params"
)
/*
Get an album from Musixmatch's database: name, release_date, release_type, cover art.
Parameters :
AlbumID - The musixmatch album id
*/
func (client *Client) GetAlbum(ctx context.Context, params ...mxmParams.Param) (*Album, error) {
var albumData album
err := client.get(ctx, "album.get", &albumData, params...)
if err != nil {
return nil, err
}
return &albumData.AlbumData, nil
}
/*
Get the list of the songs of an album.
Parameters:
AlbumID - Musixmatch album id
AlbumMbId - Musicbrainz album id
HasLyrics - When set, filter only contents with lyrics
Page - Define the page number for paginated results
PageSize - Define the page size for paginated results. Range is 1 to 100.
*/
func (client *Client) GetAlbumTracks(ctx context.Context, params ...mxmParams.Param) ([]*Track, error) {
var tracksData trackList
err := client.get(ctx, "album.tracks.get", &tracksData, params...)
if err != nil {
return nil, err
}
var tracks []*Track
for i := 0; i < len(tracksData.TrackList); i++ {
tracks = append(tracks, &tracksData.TrackList[i].TrackData)
}
return tracks, nil
}