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

AddTracksToPlaylist could not accept adding episodes of podcasts #180

Open
kerkerj opened this issue Dec 29, 2021 · 1 comment · May be fixed by #181
Open

AddTracksToPlaylist could not accept adding episodes of podcasts #180

kerkerj opened this issue Dec 29, 2021 · 1 comment · May be fixed by #181

Comments

@kerkerj
Copy link

kerkerj commented Dec 29, 2021

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

After checking the playlist section of Spotify API doc

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}

I can help with adding this btw :)

p.s. Adding this new API with accepting position argument might resolve this issue as well: #174

@strideynet
Copy link
Collaborator

I like this, happy to accept a PR implementing this.

@kerkerj kerkerj linked a pull request Jan 3, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants