From db1ebf876b092d0e9c07be5891dc50d696c55a8d Mon Sep 17 00:00:00 2001 From: jtagcat Date: Mon, 7 Feb 2022 20:26:03 +0200 Subject: [PATCH 1/2] fixup: string types to ID, where it is spotify.ID --- playlist.go | 2 +- show.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/playlist.go b/playlist.go index ea4be90..cfe0246 100644 --- a/playlist.go +++ b/playlist.go @@ -363,7 +363,7 @@ type TrackToRemove struct { // NewTrackToRemove creates a new TrackToRemove object with the specified // track ID and playlist locations. -func NewTrackToRemove(trackID string, positions []int) TrackToRemove { +func NewTrackToRemove(trackID ID, positions []int) TrackToRemove { return TrackToRemove{ URI: fmt.Sprintf("spotify:track:%s", trackID), Positions: positions, diff --git a/show.go b/show.go index b3a5955..1fffe12 100644 --- a/show.go +++ b/show.go @@ -190,8 +190,8 @@ func (c *Client) GetShow(ctx context.Context, id ID, opts ...RequestOption) (*Fu // GetShowEpisodes retrieves paginated episode information about a specific show.. // API reference: https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-a-shows-episodes // Supported options: Market, Limit, Offset -func (c *Client) GetShowEpisodes(ctx context.Context, id string, opts ...RequestOption) (*SimpleEpisodePage, error) { - spotifyURL := c.baseURL + "shows/" + id + "/episodes" +func (c *Client) GetShowEpisodes(ctx context.Context, id ID, opts ...RequestOption) (*SimpleEpisodePage, error) { + spotifyURL := c.baseURL + "shows/" + string(id) + "/episodes" if params := processOptions(opts...).urlParams.Encode(); params != "" { spotifyURL += "?" + params } From 19bfb835bdc98c6e679a007051795f8ac6dcc882 Mon Sep 17 00:00:00 2001 From: jtagcat Date: Mon, 7 Feb 2022 20:31:00 +0200 Subject: [PATCH 2/2] fixup: userID is a string, not always spotify.ID Newer profiles do look like spotify.ID, but a sizable 'legacy' chunk are just alphanumerical + few non-alphanumeric chars, most commonly dot. --- examples/profile/profile.go | 5 +++-- user.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/profile/profile.go b/examples/profile/profile.go index 17a1768..b3bdec9 100644 --- a/examples/profile/profile.go +++ b/examples/profile/profile.go @@ -5,10 +5,11 @@ import ( "context" "flag" "fmt" - spotifyauth "github.com/zmb3/spotify/v2/auth" "log" "os" + spotifyauth "github.com/zmb3/spotify/v2/auth" + "golang.org/x/oauth2/clientcredentials" "github.com/zmb3/spotify/v2" @@ -39,7 +40,7 @@ func main() { httpClient := spotifyauth.New().Client(ctx, token) client := spotify.New(httpClient) - user, err := client.GetUsersPublicProfile(ctx, spotify.ID(*userID)) + user, err := client.GetUsersPublicProfile(ctx, *userID) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) return diff --git a/user.go b/user.go index 76ef603..80e660f 100644 --- a/user.go +++ b/user.go @@ -56,7 +56,7 @@ type PrivateUser struct { // GetUsersPublicProfile gets public profile information about a // Spotify User. It does not require authentication. -func (c *Client) GetUsersPublicProfile(ctx context.Context, userID ID) (*User, error) { +func (c *Client) GetUsersPublicProfile(ctx context.Context, userID string) (*User, error) { spotifyURL := c.baseURL + "users/" + string(userID) var user User