Spotify integration hotfixes (#31835)

* Remove services file, incorrect info

* Guard currently playing for being a NoneType

* Revert "Guard currently playing for being a NoneType"

This reverts commit f5f56b0db0.

* Guard currently playing item is None

* Process review suggestions
This commit is contained in:
Franck Nijhof 2020-02-14 22:58:39 +01:00 committed by GitHub
parent 614be5c1bb
commit f396f1cb18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 12 deletions

View file

@ -157,7 +157,8 @@ class SpotifyMediaPlayer(MediaPlayerDevice):
@property
def media_content_id(self) -> Optional[str]:
"""Return the media URL."""
return self._currently_playing.get("item", {}).get("name")
item = self._currently_playing.get("item") or {}
return item.get("name")
@property
def media_content_type(self) -> Optional[str]:
@ -203,7 +204,8 @@ class SpotifyMediaPlayer(MediaPlayerDevice):
@property
def media_title(self) -> Optional[str]:
"""Return the media title."""
return self._currently_playing.get("item", {}).get("name")
item = self._currently_playing.get("item") or {}
return item.get("name")
@property
def media_artist(self) -> Optional[str]:
@ -224,7 +226,8 @@ class SpotifyMediaPlayer(MediaPlayerDevice):
@property
def media_track(self) -> Optional[int]:
"""Track number of current playing media, music track only."""
return self._currently_playing.get("item", {}).get("track_number")
item = self._currently_playing.get("item") or {}
return item.get("track_number")
@property
def media_playlist(self):

View file

@ -1,9 +0,0 @@
play_playlist:
description: Play a Spotify playlist.
fields:
media_content_id:
description: Spotify URI of the playlist.
example: 'spotify:playlist:0IpRnqCHSjun48oQRX1Dy7'
random_song:
description: True to select random song at start, False to start from beginning.
example: true