1 """Utils for Spotify."""
3 from __future__
import annotations
5 from spotifyaio
import Image
8 from .const
import MEDIA_PLAYER_PREFIX
12 """Return whether the media_content_type is a valid Spotify media_id."""
13 return media_content_type.startswith(MEDIA_PLAYER_PREFIX)
17 """Return actual spotify media_content_type."""
18 return media_content_type.removeprefix(MEDIA_PLAYER_PREFIX)
22 """Fetch image url."""
29 """Extract spotify URI from media browser URL."""
30 if media_content_id
and media_content_id.startswith(MEDIA_PLAYER_PREFIX):
31 parsed_url = yarl.URL(media_content_id)
32 media_content_id = parsed_url.name
33 return media_content_id
bool is_spotify_media_type(str media_content_type)
str resolve_spotify_media_type(str media_content_type)
str|None fetch_image_url(list[Image] images)
str spotify_uri_from_media_browser_url(str media_content_id)