Fix streaming of soundcloud (#1206)
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Fri, 5 Apr 2024 15:47:09 +0000 (17:47 +0200)
committerGitHub <noreply@github.com>
Fri, 5 Apr 2024 15:47:09 +0000 (17:47 +0200)
music_assistant/server/helpers/audio.py
music_assistant/server/providers/soundcloud/__init__.py

index fb0901683074ea9b0b9b27fd108d739a02f750b4..cd8013fa2fce88e328f2998dca103ace9b4fe446 100644 (file)
@@ -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
index 587172550bada69b618d66f4996fde3c6996b7ae..663d27460bf0cc23e57c6fa5a54aa59a0290e4d8 100644 (file)
@@ -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: