mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Make Spotify accept user playlist uris (#96820)
* Make Spotify accept user platlist uris * Fix feedback * Fix feedback
This commit is contained in:
parent
8dc5f73789
commit
1ace9ab82e
@ -398,13 +398,24 @@ class SpotifyMediaPlayer(MediaPlayerEntity):
|
|||||||
)
|
)
|
||||||
self._currently_playing = current or {}
|
self._currently_playing = current or {}
|
||||||
|
|
||||||
context = self._currently_playing.get("context")
|
context = self._currently_playing.get("context", {})
|
||||||
|
|
||||||
|
# For some users in some cases, the uri is formed like
|
||||||
|
# "spotify:user:{name}:playlist:{id}" and spotipy wants
|
||||||
|
# the type to be playlist.
|
||||||
|
uri = context.get("uri")
|
||||||
|
if uri is not None:
|
||||||
|
parts = uri.split(":")
|
||||||
|
if len(parts) == 5 and parts[1] == "user" and parts[3] == "playlist":
|
||||||
|
uri = ":".join([parts[0], parts[3], parts[4]])
|
||||||
|
|
||||||
if context is not None and (
|
if context is not None and (
|
||||||
self._playlist is None or self._playlist["uri"] != context["uri"]
|
self._playlist is None or self._playlist["uri"] != uri
|
||||||
):
|
):
|
||||||
self._playlist = None
|
self._playlist = None
|
||||||
if context["type"] == MediaType.PLAYLIST:
|
if context["type"] == MediaType.PLAYLIST:
|
||||||
self._playlist = self.data.client.playlist(current["context"]["uri"])
|
self._playlist = self.data.client.playlist(uri)
|
||||||
|
|
||||||
device = self._currently_playing.get("device")
|
device = self._currently_playing.get("device")
|
||||||
if device is not None:
|
if device is not None:
|
||||||
self._restricted_device = device["is_restricted"]
|
self._restricted_device = device["is_restricted"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user