diff --git a/music_assistant/providers/audiobookshelf/__init__.py b/music_assistant/providers/audiobookshelf/__init__.py index 34c108844..282224ef4 100644 --- a/music_assistant/providers/audiobookshelf/__init__.py +++ b/music_assistant/providers/audiobookshelf/__init__.py @@ -55,8 +55,6 @@ CONF_USERNAME = "username" CONF_PASSWORD = "password" CONF_VERIFY_SSL = "verify_ssl" -CONF_USE_SESSION_AUDIOBOOK = "use_session_audiobook" -CONF_USE_SESSION_PODCAST = "use_session_podcast" async def setup( @@ -102,24 +100,6 @@ async def get_config_entries( required=False, description="The password to authenticate to the remote server.", ), - ConfigEntry( - key=CONF_USE_SESSION_AUDIOBOOK, - type=ConfigEntryType.BOOLEAN, - label="Use session/ HLS stream for audiobooks.", - required=False, - description="Opens a session at abs, enables support for multiple file audiobooks.", - category="advanced", - default_value=True, - ), - ConfigEntry( - key=CONF_USE_SESSION_PODCAST, - type=ConfigEntryType.BOOLEAN, - label="Use session/ HLS stream for podcasts.", - required=False, - description="Opens a session at abs for podcasts.", - category="advanced", - default_value=False, - ), ConfigEntry( key=CONF_VERIFY_SSL, type=ConfigEntryType.BOOLEAN, @@ -442,38 +422,26 @@ async def get_stream_details( """Get stream of item.""" # self.logger.debug(f"Streamdetails: {item_id}") if media_type == MediaType.PODCAST_EPISODE: - if not bool(self.config.get_value(CONF_USE_SESSION_PODCAST)): - return await self._get_stream_details_podcast_episode(item_id) - abs_podcast_id, abs_episode_id = item_id.split(" ") - session = await self._client.get_playback_session_podcast( - device_info=self.device_info, - podcast_id=abs_podcast_id, - episode_id=abs_episode_id, - ) - return await self.get_streamdetails_from_playback_session(session) + return await self._get_stream_details_podcast_episode(item_id) elif media_type == MediaType.AUDIOBOOK: - if not bool(self.config.get_value(CONF_USE_SESSION_AUDIOBOOK)): - return await self._get_stream_details_audiobook(item_id) - session = await self._client.get_playback_session_audiobook( - device_info=self.device_info, audiobook_id=item_id - ) - return await self.get_streamdetails_from_playback_session(session) + abs_audiobook = await self._client.get_audiobook(item_id) + tracks = abs_audiobook.media.tracks + if len(tracks) == 0: + raise MediaNotFoundError("Stream not found") + if len(tracks) > 1: + session = await self._client.get_playback_session_audiobook( + device_info=self.device_info, audiobook_id=item_id + ) + return await self.get_streamdetails_from_playback_session(session) + return await self._get_stream_details_audiobook(abs_audiobook) raise MediaNotFoundError("Stream unknown") - async def _get_stream_details_audiobook(self, audiobook_id: str) -> StreamDetails: + async def _get_stream_details_audiobook(self, abs_audiobook: ABSAudioBook) -> StreamDetails: """Only single audio file in audiobook.""" - abs_audiobook = await self._client.get_audiobook(audiobook_id) self.logger.debug( f"Using direct playback for audiobook {abs_audiobook.media.metadata.title}" ) tracks = abs_audiobook.media.tracks - if len(tracks) == 0: - raise MediaNotFoundError("Stream not found") - if len(tracks) > 1: - self.logger.warning( - "Music Assistant only supports single file based audiobooks. " - "Switch to HLS stream for multiple file audiobooks." - ) token = self._client.token base_url = str(self.config.get_value(CONF_URL)) media_url = tracks[0].content_url @@ -482,7 +450,7 @@ async def _get_stream_details_audiobook(self, audiobook_id: str) -> StreamDetail # to lift unknown at some point. return StreamDetails( provider=self.lookup_key, - item_id=audiobook_id, + item_id=abs_audiobook.id_, audio_format=AudioFormat( content_type=ContentType.UNKNOWN, ),