Minor readability improvement of Spotify browse media (#138907)

This commit is contained in:
Erik Montnemery 2025-02-20 08:45:36 +01:00 committed by GitHub
parent 14375e76a3
commit 1c3d6b5641
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -226,17 +226,17 @@ async def async_browse_media(
if media_content_id is None or not media_content_id.startswith(MEDIA_PLAYER_PREFIX):
raise BrowseError("Invalid Spotify URL specified")
# Check for config entry specifier, and extract Spotify URI
# The config entry id is the host name of the URL, the Spotify URI is the name
parsed_url = yarl.URL(media_content_id)
host = parsed_url.host
config_entry_id = parsed_url.host
if (
host is None
config_entry_id is None
# config entry ids can be upper or lower case. Yarl always returns host
# names in lower case, so we need to look for the config entry in both
or (
entry := hass.config_entries.async_get_entry(host)
or hass.config_entries.async_get_entry(host.upper())
entry := hass.config_entries.async_get_entry(config_entry_id)
or hass.config_entries.async_get_entry(config_entry_id.upper())
)
is None
or entry.state is not ConfigEntryState.LOADED