Skip to content

Commit

Permalink
Fix media image url for AirPlay
Browse files Browse the repository at this point in the history
  • Loading branch information
hchris1 committed Oct 6, 2023
1 parent 01c4b60 commit 1381382
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 5 additions & 1 deletion custom_components/eversolo/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,14 @@ async def async_set_output(self, index, tag) -> any:
parseJson=False,
)

def create_internal_image_url(self, song_id) -> any:
def create_image_url_by_song_id(self, song_id) -> any:
"""Create url to fetch album covers when using the internal player."""
return f"http://{self._host}:{self._port}/ZidooMusicControl/v2/getImage?id={song_id}&target=16"

def create_image_url_by_path(self, path) -> any:
"""Create url to fetch album covers when using AirPlay by concatting the path."""
return f"http://{self._host}:{self._port}{path}"

async def _api_wrapper(
self,
method: str,
Expand Down
17 changes: 10 additions & 7 deletions custom_components/eversolo/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,23 @@ def media_image_url(self):

# Bluetooth or Spotify Connect
if play_type == 6:
album_url = (
music_control_state.get("everSoloPlayInfo", {})
.get("everSoloPlayAudioInfo", {})
.get("albumUrl", None)
album_url = music_control_state.get("everSoloPlayInfo", {}).get(
"icon", None
)

if album_url is not None:
return album_url
if album_url is None or album_url == "":
return None

if not album_url.startswith("http"):
album_url = self.coordinator.client.create_image_url_by_path(album_url)

return album_url

# Internal Player
if play_type == 5:
song_id = music_control_state.get("playingMusic", {}).get("id", None)
if song_id is not None:
return self.coordinator.client.create_internal_image_url(song_id)
return self.coordinator.client.create_image_url_by_song_id(song_id)

return None

Expand Down

0 comments on commit 1381382

Please sign in to comment.