Add service to Spotify integration to add song to playlist

When listening to other people’s playlists, I often want to save a song to one of my playlists. I do this now via IFTTT. A service that takes an argument of a playlist ID and a track ID would be handy.

aside:
I thought I could figure out something by grabbing the access token from ‘/config/.spotify-token-cache’ and use it in AppDaemon, but the Spotify integration’s token scope doesn’t allow ‘playlist-modify-private’ or ‘playlist-modify-public’ and I’m not savvy enough to figure out how to generate a new token with that scope.

@ih8gates @OzStone @m4tthall73 in case you are still looking to add a song to a Spotify playlist via a service …

I developed the SpotifyPlus integration that could be modified to do this. Would something like the following work? Note that it does not exist, but could be easily added.

service: spotifyplus.playlist_items_add
data:
  entity_id: media_player.spotifyplus_john_s
  playlist_id: 6M8n0Sp9895BXEE0MbGPde
  uris: spotify:track:4iV5W9uYEdYUVa79Axb7Rh,spotify:episode:512ojhOuo1ktJprKbVcKyQ
  position: 0

Parameters would be:

  • playlist _id:
    The Spotify ID of the playlist.
    Example: 5AC9ZXA7nJ7oGWO911FuDG

  • uris (str):
    A comma-separated list of Spotify URIs to add; can be track or episode URIs.
    Example: spotify:track:4iV5W9uYEdYUVa79Axb7Rh,spotify:episode:512ojhOuo1ktJprKbVcKyQ.
    A maximum of 100 items can be added in one request.

  • position (int):
    The position to insert the items, a zero-based index.
    For example, to insert the items in the first position: position=0;
    to insert the items in the third position: position=2.
    If omitted, the items will be appended to the playlist.
    Items are added in the order they are listed in the uris argument.

Check out the SpotifyPlus integration wiki for more information.

Hope it helps.

@ih8gates @OzStone @m4tthall73
FYI - just released v1.0.8 of the SpotifyPlus integration:

  • Added service playlist_items_add to add one or more items to a user’s playlist. Items are added in the order they are listed in the uris argument.
1 Like