From c2cb00fba5e33ca4c077675b054f6a90cbee2739 Mon Sep 17 00:00:00 2001 From: cdnninja Date: Mon, 17 Jun 2024 15:42:37 -0600 Subject: [PATCH] Correct track chapter play --- custom_components/yoto/coordinator.py | 4 ++++ custom_components/yoto/media_player.py | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/custom_components/yoto/coordinator.py b/custom_components/yoto/coordinator.py index f9ff978..9c766c4 100644 --- a/custom_components/yoto/coordinator.py +++ b/custom_components/yoto/coordinator.py @@ -162,6 +162,10 @@ async def async_play_card( chapter: int = 1, trackkey: int = 1, ) -> None: + if trackkey is None: + trackkey = 1 + if chapter is None: + trackkey = 1 await self.async_check_and_refresh_token() await self.hass.async_add_executor_job( self.yoto_manager.play_card, diff --git a/custom_components/yoto/media_player.py b/custom_components/yoto/media_player.py index ab0123f..832cb6d 100644 --- a/custom_components/yoto/media_player.py +++ b/custom_components/yoto/media_player.py @@ -87,8 +87,11 @@ async def async_play_media( **kwargs: Any, ) -> None: cardid, chapterid, trackid = split_media_id(media_id) + _LOGGER.debug( + f"{DOMAIN} - Media requested: {media_id} Cardid: {cardid}, chapterid: {chapterid}, trackid: {trackid}" + ) await self.coordinator.async_play_card( - self.player.id, cardid, chapterid, trackid + player_id=self.player.id, cardid=cardid, chapter=chapterid, trackkey=trackid ) async def async_set_volume_level(self, volume: float) -> None: @@ -108,8 +111,6 @@ async def async_browse_media( if media_content_id in (None, "library"): return await self.async_convert_library_to_browse_media() else: - _LOGGER.debug(f"{DOMAIN} - Getting chapters") - return await self.async_convert_chapter_to_browse_media(media_content_id) async def async_convert_library_to_browse_media(self) -> list: