mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Handle TypeError in Spotify (#114317)
This commit is contained in:
parent
c518acfef3
commit
544215a609
@ -21,10 +21,10 @@ def resolve_spotify_media_type(media_content_type: str) -> str:
|
|||||||
|
|
||||||
def fetch_image_url(item: dict[str, Any], key="images") -> str | None:
|
def fetch_image_url(item: dict[str, Any], key="images") -> str | None:
|
||||||
"""Fetch image url."""
|
"""Fetch image url."""
|
||||||
try:
|
source = item.get(key, [])
|
||||||
return item.get(key, [])[0].get("url")
|
if isinstance(source, list) and source:
|
||||||
except IndexError:
|
return source[0].get("url")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def spotify_uri_from_media_browser_url(media_content_id: str) -> str:
|
def spotify_uri_from_media_browser_url(media_content_id: str) -> str:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user