From e74fc7d6f43f9863eb38282047bf274812e38ff2 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 5 Apr 2024 17:47:09 +0200 Subject: [PATCH] Fix streaming of soundcloud (#1206) --- music_assistant/server/helpers/audio.py | 4 ++-- music_assistant/server/providers/soundcloud/__init__.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/music_assistant/server/helpers/audio.py b/music_assistant/server/helpers/audio.py index fb090168..cd8013fa 100644 --- a/music_assistant/server/helpers/audio.py +++ b/music_assistant/server/helpers/audio.py @@ -460,8 +460,8 @@ async def get_hls_stream( charset = resp.charset or "utf-8" master_m3u_data = await resp.text(charset) substreams = parse_m3u(master_m3u_data) - if any(x for x in substreams if x.path.endswith(".ts")) or not all( - x for x in substreams if x.stream_info is not None + if any(x for x in substreams if x.path.endswith(".ts")) or all( + x for x in substreams if (x.stream_info or x.length) ): # the url we got is already a substream substream_url = url diff --git a/music_assistant/server/providers/soundcloud/__init__.py b/music_assistant/server/providers/soundcloud/__init__.py index 58717255..663d2746 100644 --- a/music_assistant/server/providers/soundcloud/__init__.py +++ b/music_assistant/server/providers/soundcloud/__init__.py @@ -301,17 +301,17 @@ class SoundcloudMusicProvider(MusicProvider): async def get_stream_details(self, item_id: str) -> StreamDetails: """Return the content details for the given track when it will be streamed.""" - track_details = await self._soundcloud.get_track_details(track_id=item_id) - stream_format = track_details[0]["media"]["transcodings"][0]["format"]["mime_type"] url = await self._soundcloud.get_stream_url(track_id=item_id) return StreamDetails( provider=self.instance_id, item_id=item_id, + # let ffmpeg work out the details itself as + # soundcloud uses a mix of different content types and streaming methods audio_format=AudioFormat( - content_type=ContentType.try_parse(stream_format), + content_type=ContentType.UNKNOWN, ), stream_type=StreamType.HTTP, - data=url, + path=url, ) async def _parse_artist(self, artist_obj: dict) -> Artist: -- 2.34.1