mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Minor readability improvement of Spotify browse media (#138907)
This commit is contained in:
parent
14375e76a3
commit
1c3d6b5641
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user