Handle TypeError in Spotify (#114317)

This commit is contained in:
Joost Lekkerkerker 2024-03-27 17:56:22 +01:00 committed by GitHub
parent c518acfef3
commit 544215a609
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: