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,9 +21,9 @@ def resolve_spotify_media_type(media_content_type: str) -> str:
def fetch_image_url(item: dict[str, Any], key="images") -> str | None:
"""Fetch image url."""
try:
return item.get(key, [])[0].get("url")
except IndexError:
source = item.get(key, [])
if isinstance(source, list) and source:
return source[0].get("url")
return None