I have been looking for a solution to this for two days now and can’t find the answer. I am making a custom_component for airmusic radios, the code is here:
https://github.com/DominikWrobel/airmusic
It works ok, but I want to have a radio station logo displayed in the media_player card. The airmusic radios have either no auth or basic auth with a set credentials. I have one of each. If I use this code:
# If powered on
if self._pwstate == 'playing':
playinfo_xml = await self.request_call('/playinfo')
soup = BeautifulSoup(playinfo_xml, features = "xml")
servicename = soup.station_info.renderContents().decode('UTF8')
reference = soup.sid.renderContents().decode('UTF8')
eventtitle = soup.song.renderContents().decode('UTF8')
eventid = soup.artist.renderContents().decode('UTF8')
response = await self.hass.async_add_executor_job(
requests.get,
'http://' + self._host + ':' + str(self._port) + '/playlogo.jpg',
{'auth': HTTPBasicAuth('su3g4go6sk7', 'ji39454xu/^')}
)
self._image_url = response.url
_LOGGER.debug("Airmusic: [update] - Eventtitle for host %s = %s",
self._host, eventtitle)
# Info of selected source and title
self._selected_source = servicename
self._selected_media_content_id = eventid
self._selected_media_title = servicename + ' - ' + eventid + ' - ' + eventtitle
Logs:
2024-07-07 18:26:27.998 DEBUG (MainThread) [custom_components.airmusic] Airmusic: [media_image_url] - http://192.168.0.248:8080/playlogo.jpg?auth=%3Crequests.auth.HTTPBasicAuth+object+at+0x7ffbdc700c50%3E
2024-07-07 18:26:28.032 DEBUG (MainThread) [custom_components.airmusic] Airmusic: [media_image_url] - http://192.168.0.248:8080/playlogo.jpg?auth=%3Crequests.auth.HTTPBasicAuth+object+at+0x7ffbdc700c50%3E
2024-07-07 18:26:31.217 DEBUG (MainThread) [custom_components.airmusic] Airmusic: [media_image_url] - http://192.168.0.248:8080/playlogo.jpg?auth=%3Crequests.auth.HTTPBasicAuth+object+at+0x7ffbdc700c50%3E
2024-07-07 18:30:54.687 DEBUG (MainThread) [custom_components.airmusic] Airmusic: [media_image_url] - http://192.168.0.248:8080/playlogo.jpg?auth=%3Crequests.auth.HTTPBasicAuth+object+at+0x7f77abb1b680%3E
2024-07-07 18:30:54.720 DEBUG (MainThread) [custom_components.airmusic] Airmusic: [media_image_url] - http://192.168.0.248:8080/playlogo.jpg?auth=%3Crequests.auth.HTTPBasicAuth+object+at+0x7f77abb1b680%3E
The radio with no authentication displays radio logo and updates it when I change the station, but if I use this code:
response = await self.hass.async_add_executor_job(
requests.get,
'http://su3g4go6sk7:ji39454xu%2F^@' + self._host + ':' + str(self._port) + '/playlogo.jpg'
)
self._image_url = response.url
Both radios display the logo but it won’t update after the change of station! It is the first logo the integration loads, and even after power cycle it stays the same.
Logs:
2024-07-07 20:00:39.499 DEBUG (MainThread) [custom_components.airmusic] Airmusic: [media_image_url] - http://su3g4go6sk7:ji39454xu%2F%[email protected]:8080/playlogo.jpg
2024-07-07 20:00:50.279 DEBUG (MainThread) [custom_components.airmusic] Airmusic: [media_image_url] - http://su3g4go6sk7:ji39454xu%2F%[email protected]:8080/playlogo.jpg
2024-07-07 20:02:09.588 DEBUG (MainThread) [custom_components.airmusic] Airmusic: [media_image_url] - http://su3g4go6sk7:ji39454xu%2F%[email protected]:8080/playlogo.jpg
What am I missing? It is my first try with python and coding but for this integration everything I want is working, except the logo.