From 1c3d6b5641d277c1bf4c21693a7056cf12bf1353 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 20 Feb 2025 08:45:36 +0100 Subject: [PATCH] Minor readability improvement of Spotify browse media (#138907) --- homeassistant/components/spotify/browse_media.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/spotify/browse_media.py b/homeassistant/components/spotify/browse_media.py index 458525dde28..686431da249 100644 --- a/homeassistant/components/spotify/browse_media.py +++ b/homeassistant/components/spotify/browse_media.py @@ -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