From de816686801401730c7ac050c78779c50e5c45ef Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sun, 16 Jun 2019 17:54:07 +0200 Subject: [PATCH] try to fix queue crash if qobuz does not return stream details --- music_assistant/modules/http_streamer.py | 2 +- music_assistant/modules/musicproviders/qobuz.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/music_assistant/modules/http_streamer.py b/music_assistant/modules/http_streamer.py index 83c451e2..f49a5a10 100755 --- a/music_assistant/modules/http_streamer.py +++ b/music_assistant/modules/http_streamer.py @@ -317,7 +317,7 @@ class HTTPStreamer(): streamdetails = asyncio.run_coroutine_threadsafe( self.mass.music.providers[provider].get_stream_details(track_id), self.mass.event_loop).result() if not streamdetails: - yield b'' + yield (True, b'') return # TODO: add support for AAC streams (which sox doesn't natively support) if streamdetails['type'] == 'url': diff --git a/music_assistant/modules/musicproviders/qobuz.py b/music_assistant/modules/musicproviders/qobuz.py index f4c94a0d..7acd3e98 100644 --- a/music_assistant/modules/musicproviders/qobuz.py +++ b/music_assistant/modules/musicproviders/qobuz.py @@ -254,13 +254,15 @@ class QobuzProvider(MusicProvider): async def get_stream_details(self, track_id): ''' return the content details for the given track when it will be streamed''' - # TODO: Report streaming start and streaming end !! - params = {'format_id': 27, 'track_id': track_id, 'intent': 'stream'} - streamdetails = await self.__get_data('track/getFileUrl', params, sign_request=True, ignore_cache=True) - if not streamdetails: - # simply retry this request - await asyncio.sleep(2) + for format_id in [27, 7, 6, 5]: + # 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': track_id, 'intent': 'stream'} streamdetails = await self.__get_data('track/getFileUrl', params, sign_request=True, ignore_cache=True) + if streamdetails and streamdetails.get('url'): + break + else: + await asyncio.sleep(1) if not streamdetails or not streamdetails.get('url'): LOGGER.error("Unable to retrieve stream url for track %s" % track_id) return None -- 2.34.1