fix stream error issue
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 31 Oct 2020 11:09:45 +0000 (12:09 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 31 Oct 2020 11:09:45 +0000 (12:09 +0100)
music_assistant/constants.py
music_assistant/managers/streams.py
music_assistant/providers/qobuz/__init__.py

index 5aa5052ceca62571dfdda7bbaf9a14a7899e3513..9465784772336d39e6d0a038043740a029c00de1 100755 (executable)
@@ -1,6 +1,6 @@
 """All constants for Music Assistant."""
 
-__version__ = "0.0.59"
+__version__ = "0.0.60"
 REQUIRED_PYTHON_VER = "3.7"
 
 # configuration keys/attributes
index 0a2da09678c04024480f60550cd684f8357b6dba..39f6d81304ae6ada5864e7dbb1be07fff3a0bf42 100755 (executable)
@@ -236,8 +236,7 @@ class StreamManager:
 
                 # HANDLE FIRST PART OF TRACK
                 if not chunk and cur_chunk == 1 and is_last_chunk:
-                    LOGGER.warning("Stream error, skip track %s", queue_track.item_id)
-                    break
+                    raise RuntimeError("Stream error on track %s" % queue_track.item_id)
                 if cur_chunk <= 2 and not last_fadeout_data:
                     # no fadeout_part available so just pass it to the output directly
                     yield chunk
index d49fb5cbc690c881b2222eb14cdd6cc57edabf93..49e692e0ee6d04105a7e3086b6f90e0b49378a75 100644 (file)
@@ -342,20 +342,28 @@ class QobuzProvider(MusicProvider):
             # it seems that simply requesting for highest available quality does not work
             # from time to time the api response is empty for this request ?!
             params = {"format_id": format_id, "track_id": item_id, "intent": "stream"}
-            streamdata = await self.__async_get_data(
+            result = await self.__async_get_data(
                 "track/getFileUrl", params, sign_request=True
             )
-            if streamdata and streamdata.get("url"):
+            if result and result.get("url"):
+                streamdata = result
                 break
-        if not streamdata or not streamdata.get("url"):
-            LOGGER.error("Unable to retrieve stream url for track %s", item_id)
+        if not streamdata:
+            LOGGER.error("Unable to retrieve stream details for track %s", item_id)
+            return None
+        if streamdata["mime_type"] == "audio/mpeg":
+            content_type = ContentType.MPEG
+        elif streamdata["mime_type"] == "audio/flac":
+            content_type = ContentType.FLAC
+        else:
+            LOGGER.error("Unsupported mime type for track %s", item_id)
             return None
         return StreamDetails(
             type=StreamType.URL,
             item_id=str(item_id),
             provider=PROV_ID,
             path=streamdata["url"],
-            content_type=ContentType(streamdata["mime_type"].split("/")[1]),
+            content_type=content_type,
             sample_rate=int(streamdata["sampling_rate"] * 1000),
             bit_depth=streamdata["bit_depth"],
             details=streamdata,  # we need these details for reporting playback