Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetArtistAlbumsOpt: Improvements and bug fixes #116

Merged
merged 2 commits into from
Mar 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions artist.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,19 @@ func (c *Client) GetArtistAlbums(artistID ID) (*SimpleAlbumPage, error) {
// GetArtistAlbumsOpt is just like GetArtistAlbums, but it accepts optional
// parameters used to filter and sort the result.
//
// The AlbumType argument can be used to find a particular type of album. Search
// for multiple types by OR-ing the types together. If the market (Options) is
// not specified, Spotify will likely return a lot of duplicates (one for each
// market in which the album is available)
func (c *Client) GetArtistAlbumsOpt(artistID ID, options *Options, t *AlbumType) (*SimpleAlbumPage, error) {
// The AlbumType argument can be used to find a particular types of album.
// If the market (Options) is not specified, Spotify will likely return a lot
// of duplicates (one for each market in which the album is available)
func (c *Client) GetArtistAlbumsOpt(artistID ID, options *Options, ts ...*AlbumType) (*SimpleAlbumPage, error) {
spotifyURL := fmt.Sprintf("%sartists/%s/albums", c.baseURL, artistID)
// add optional query string if options were specified
values := url.Values{}
if t != nil {
values.Set("album_type", t.encode())
if ts != nil {
types := make([]string, len(ts))
for i := range ts {
types[i] = ts[i].encode()
}
values.Set("include_groups", strings.Join(types, ","))
}
if options != nil {
if options.Country != nil {
Expand Down