@@ -67,6 +67,9 @@ async def async_update(self) -> bool | None:
6767 self ._night_mode = await self ._async_get_request (UrlSuffix .GET_NIGHT_MODE )
6868 self ._equalizer = await self ._async_get_request (UrlSuffix .GET_EQUALIZER )
6969
70+ if self .source == "upnp" :
71+ return True
72+
7073 try :
7174 self ._media_duration = self ._source_state ["metadata" ]["duration" ]
7275 except (KeyError , TypeError ):
@@ -574,6 +577,7 @@ async def async_play_url_source(self, media_url: str, media_title: str, meta_dat
574577 LOGGER .error ("Error playing %s %s" , media_title , x .text )
575578
576579 await self .async_upnp_play ()
580+ await self ._async_get_upnp_metadata (media_url ) # Devialet does not support UPnP metadata
577581
578582 async def async_upnp_play (self ) -> None :
579583 """Send the play command over UPnP."""
@@ -591,3 +595,26 @@ async def async_upnp_play(self) -> None:
591595 return
592596 except UpnpXmlParseError :
593597 return
598+
599+ async def _async_get_upnp_metadata (self , url : str ) -> any | None :
600+ """Call the media URL with the HEAD method to get ICY metadata."""
601+ try :
602+ async with self ._session .head (
603+ url = url , allow_redirects = False , timeout = 2 , headers = {"Icy-MetaData" : 1 }
604+ ) as response :
605+ LOGGER .debug (
606+ "Host %s: HTTP Response data: %s" ,
607+ self ._host ,
608+ response .headers ,
609+ )
610+ title :str = response .headers .get ("icy-name" )
611+ self ._source_state = { "metadata" : { "title" : title } }
612+
613+ except aiohttp .ClientConnectorError :
614+ return None
615+ except asyncio .TimeoutError :
616+ return None
617+ except TypeError :
618+ return None
619+ except Exception : # pylint: disable=bare-except
620+ return None
0 commit comments