mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Handle nullable context in Spotify (#96913)
This commit is contained in:
parent
29aa89bea0
commit
0f4c71f993
@ -398,7 +398,7 @@ 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") or {}
|
||||||
|
|
||||||
# For some users in some cases, the uri is formed like
|
# For some users in some cases, the uri is formed like
|
||||||
# "spotify:user:{name}:playlist:{id}" and spotipy wants
|
# "spotify:user:{name}:playlist:{id}" and spotipy wants
|
||||||
@ -409,9 +409,7 @@ class SpotifyMediaPlayer(MediaPlayerEntity):
|
|||||||
if len(parts) == 5 and parts[1] == "user" and parts[3] == "playlist":
|
if len(parts) == 5 and parts[1] == "user" and parts[3] == "playlist":
|
||||||
uri = ":".join([parts[0], parts[3], parts[4]])
|
uri = ":".join([parts[0], parts[3], parts[4]])
|
||||||
|
|
||||||
if context is not None and (
|
if context and (self._playlist is None or self._playlist["uri"] != 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(uri)
|
self._playlist = self.data.client.playlist(uri)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user