'add to queue' endpoint added (#452)

This commit is contained in:
Peter-Schorn 2020-03-12 19:58:04 -05:00 committed by GitHub
parent 37b6b5fd80
commit 9315d00990
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1291,6 +1291,30 @@ class Spotify(object):
) )
) )
def add_to_queue(self, uri, device_id=None):
""" Adds a song to the end of a user's queue
If device A is currently playing music and you try to add to the queue
and pass in the id for device B, you will get a
'Player command failed: Restriction violated' error
I therefore reccomend leaving device_id as None so that the active device is targeted
:param uri: song uri, id, or url
:param device_id:
the id of a Spotify device.
If None, then the active device is used.
"""
uri = self._get_uri("track", uri)
endpoint = "me/player/queue?uri=%s" % uri
if device_id is not None:
endpoint += "&device_id=%s" % device_id
return self._post(endpoint)
def _append_device_id(self, path, device_id): def _append_device_id(self, path, device_id):
""" Append device ID to API path. """ Append device ID to API path.