mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix non-radio Sonos album-art by using track_info['album_art'] before checking other options. (#4958)
* Fix Sonos album art for non-radio streams * Revert "Fix Sonos album art for non-radio streams" This reverts commit d71502d18f5778146cf45dcb717aba71f88a3fac. * Fix Sonos album art for non-radio streams * Move art existance check into _format_media_image_url
This commit is contained in:
parent
a6d995e394
commit
744d00a36e
@ -424,6 +424,7 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
media_artist = track_info.get('artist')
|
media_artist = track_info.get('artist')
|
||||||
media_album_name = track_info.get('album')
|
media_album_name = track_info.get('album')
|
||||||
media_title = track_info.get('title')
|
media_title = track_info.get('title')
|
||||||
|
media_image_url = track_info.get('album_art', None)
|
||||||
|
|
||||||
media_position = None
|
media_position = None
|
||||||
media_position_updated_at = None
|
media_position_updated_at = None
|
||||||
@ -454,6 +455,7 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
|
|
||||||
elif is_radio_stream:
|
elif is_radio_stream:
|
||||||
media_image_url = self._format_media_image_url(
|
media_image_url = self._format_media_image_url(
|
||||||
|
media_image_url,
|
||||||
current_media_uri
|
current_media_uri
|
||||||
)
|
)
|
||||||
support_previous_track = False
|
support_previous_track = False
|
||||||
@ -521,6 +523,7 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
else:
|
else:
|
||||||
# not a radio stream
|
# not a radio stream
|
||||||
media_image_url = self._format_media_image_url(
|
media_image_url = self._format_media_image_url(
|
||||||
|
media_image_url,
|
||||||
track_info['uri']
|
track_info['uri']
|
||||||
)
|
)
|
||||||
support_previous_track = True
|
support_previous_track = True
|
||||||
@ -647,12 +650,14 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
|
|
||||||
self._last_avtransport_event = None
|
self._last_avtransport_event = None
|
||||||
|
|
||||||
def _format_media_image_url(self, uri):
|
def _format_media_image_url(self, url, fallback_uri):
|
||||||
return 'http://{host}:{port}/getaa?s=1&u={uri}'.format(
|
if url in ('', 'NOT_IMPLEMENTED', None):
|
||||||
host=self._player.ip_address,
|
return 'http://{host}:{port}/getaa?s=1&u={uri}'.format(
|
||||||
port=1400,
|
host=self._player.ip_address,
|
||||||
uri=urllib.parse.quote(uri)
|
port=1400,
|
||||||
)
|
uri=urllib.parse.quote(fallback_uri)
|
||||||
|
)
|
||||||
|
return url
|
||||||
|
|
||||||
def process_sonos_event(self, event):
|
def process_sonos_event(self, event):
|
||||||
"""Process a service event coming from the speaker."""
|
"""Process a service event coming from the speaker."""
|
||||||
@ -672,6 +677,7 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
next_track_uri = event.variables.get('next_track_uri')
|
next_track_uri = event.variables.get('next_track_uri')
|
||||||
if next_track_uri:
|
if next_track_uri:
|
||||||
next_track_image_url = self._format_media_image_url(
|
next_track_image_url = self._format_media_image_url(
|
||||||
|
None,
|
||||||
next_track_uri
|
next_track_uri
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user