In AddTracksToPlaylist method, the arguments are provided in form of ID strings, instead of providing URI.
The src code:
func (c *Client) AddTracksToPlaylist(ctx context.Context, playlistID ID, trackIDs ...ID) (snapshotID string, err error) {
uris := make([]string, len(trackIDs))
for i, id := range trackIDs {
uris[i] = fmt.Sprintf("spotify:track:%s", id)
}
m := make(map[string]interface{})
m["uris"] = uris
uris[i] = fmt.Sprintf("spotify:track:%s", id)
☝️ This limits from adding episodes of podcasts to the playlist, because the URI of episodes is like spotify:episode:XXXXXXXX
How about adding a new API AddItemsToPlaylist with the same approach of AddTracksToPlaylist,
the only difference is that AddItemsToPlaylist accepts URI instead of ID to gain more flexibility without breaking the AddTracksToPlaylist API behavior?
example:
func (c *Client) AddItemsToPlaylist(ctx context.Context, playlistID ID, position int, items ...URI) (snapshotID string, err error) { /* To be implemented */}
// accepts:
// {"uris": ["spotify:track:4iV5W9uYEdYUVa79Axb7Rh","spotify:track:1301WleyT98MSxVHPZCA6M","spotify:episode:1311WleyT98MSxVHPZCA6M"], "position": 3}
In
AddTracksToPlaylist
method, the arguments are provided in form of ID strings, instead of providing URI.The src code:
uris[i] = fmt.Sprintf("spotify:track:%s", id)
☝️ This limits from adding episodes of podcasts to the playlist, because the URI of episodes is likespotify:episode:XXXXXXXX
After checking the playlist section of Spotify API doc
How about adding a new API
AddItemsToPlaylist
with the same approach ofAddTracksToPlaylist
, the only difference is thatAddItemsToPlaylist
acceptsURI
instead ofID
to gain more flexibility without breaking theAddTracksToPlaylist
API behavior?example:
I can help with adding this btw :)
p.s. Adding this new API with accepting
position
argument might resolve this issue as well: https://github.com/zmb3/spotify/issues/174