From 39c2c884989f13090da64d9f34def42414a7de21 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sat, 31 Oct 2020 12:09:45 +0100 Subject: [PATCH] fix stream error issue --- music_assistant/constants.py | 2 +- music_assistant/managers/streams.py | 3 +-- music_assistant/providers/qobuz/__init__.py | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/music_assistant/constants.py b/music_assistant/constants.py index 5aa5052c..94657847 100755 --- a/music_assistant/constants.py +++ b/music_assistant/constants.py @@ -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 diff --git a/music_assistant/managers/streams.py b/music_assistant/managers/streams.py index 0a2da096..39f6d813 100755 --- a/music_assistant/managers/streams.py +++ b/music_assistant/managers/streams.py @@ -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 diff --git a/music_assistant/providers/qobuz/__init__.py b/music_assistant/providers/qobuz/__init__.py index d49fb5cb..49e692e0 100644 --- a/music_assistant/providers/qobuz/__init__.py +++ b/music_assistant/providers/qobuz/__init__.py @@ -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 -- 2.34.1