mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
'add to queue' endpoint added (#452)
This commit is contained in:
parent
37b6b5fd80
commit
9315d00990
@ -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.
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user