Spotify: service to implement adding tracks to a specified playlist

I’d like to find a way to add the current track to a specified Spotify playlist.

It seems to me that to support this, the spotify media_player component would first need to retain the URI of the current track to media_content_id.

Then the component would need to expose a service to add a track (or list of tracks) to a specified playlist using spotipy’s user_playlist_add_tracks

Something like:

    service: media_player.add_to_playlist
    entity_id: media_player.spotify
    data:
        playlist_id: spotify:user:ih8gates:playlist:3C4vzY7mOqylGLmGRlPplf
        track_id: spotify:track:6jvtd5tY3vwlHh4kOXRL8c

OK. So, I’m GIT-challenged. I can’t remember how to create a PR.

I think that there’s a small mistake in spotify.py that’s preventing media_content_id from retaining the Spotify_URL.

On line 197:
self._uri = current.get('uri')
should be
self._uri = item.get('uri')

I tested this in my local custom_components and it’s working for me. Can someone help me test/make that update.

+1 for the request! Would love to have this!

I’ve submitted a PR to correct the blank media_content_id

Would someone familiar with the Spotify component be willing to implement this service? The Kodi component provides media_player.kodi_add_to_playlis that could be used as a similar example.

Looks like the Spotipy function is user_playlist_add_tracks.
http://spotipy.readthedocs.io/en/latest/#examples