small fixes
authormarcelveldt <marcelvanderveldt@MacBook-Silvia.local>
Thu, 24 Oct 2019 22:37:05 +0000 (00:37 +0200)
committermarcelveldt <marcelvanderveldt@MacBook-Silvia.local>
Thu, 24 Oct 2019 22:37:05 +0000 (00:37 +0200)
music_assistant/http_streamer.py
music_assistant/musicproviders/qobuz.py

index f32925f1c785c940c78707a47b11958c2b2f40a1..412bc6ec662629f0163a70277e9f9cf405c8fc16 100755 (executable)
@@ -80,7 +80,7 @@ class HTTPStreamer():
             # put chunk in buffer
             self.mass.create_task(
                     buffer.write(audio_chunk), wait_for_result=True, 
-                        ignore_exception=BrokenPipeError)
+                        ignore_exception=(BrokenPipeError,ConnectionResetError))
         # all chunks received: streaming finished
         if cancelled.is_set():
             LOGGER.debug("stream single track interrupted for track %s on player %s" % (queue_item.name, player.name))
@@ -88,7 +88,7 @@ class HTTPStreamer():
             # indicate EOF if no more data
             self.mass.create_task(
                     buffer.write_eof(), wait_for_result=True, 
-                        ignore_exception=BrokenPipeError)
+                        ignore_exception=(BrokenPipeError,ConnectionResetError))
             LOGGER.debug("stream single track finished for track %s on player %s" % (queue_item.name, player.name))
 
     def __get_queue_stream(self, player, buffer, cancelled):
@@ -116,12 +116,12 @@ class HTTPStreamer():
                     break
                 if chunk and not cancelled.is_set():
                     self.mass.create_task(buffer.write(chunk), 
-                        wait_for_result=True, ignore_exception=BrokenPipeError)
+                        wait_for_result=True, ignore_exception=(BrokenPipeError,ConnectionResetError))
                 del chunk
             # indicate EOF if no more data
             if not cancelled.is_set():
                 self.mass.create_task(buffer.write_eof(), 
-                    wait_for_result=True, ignore_exception=BrokenPipeError)
+                    wait_for_result=True, ignore_exception=(BrokenPipeError,ConnectionResetError))
         # start fill buffer task in background
         fill_buffer_thread = threading.Thread(target=fill_buffer)
         fill_buffer_thread.start()
index 25166cce5092f6f4e2d7959dcd207fd9c3500a39..b1c850daca498a32adecef6702e634fa709f054f 100644 (file)
@@ -17,7 +17,7 @@ from ..app_vars import get_app_var
 from ..models import MusicProvider, MediaType, TrackQuality, \
         AlbumType, Artist, Album, Track, Playlist
 from ..constants import CONF_USERNAME, CONF_PASSWORD, CONF_ENABLED, \
-        CONF_TYPE_PASSWORD, EVENT_PLAYBACK_STARTED, EVENT_PLAYBACK_STOPPED
+        CONF_TYPE_PASSWORD, EVENT_STREAM_STARTED, EVENT_PLAYBACK_STOPPED
 
 PROV_ID = 'qobuz'
 PROV_NAME = 'Qobuz'
@@ -50,7 +50,7 @@ class QobuzProvider(MusicProvider):
         self.http_session = aiohttp.ClientSession(
                 loop=self.mass.event_loop, connector=aiohttp.TCPConnector())
         self.throttler = Throttler(rate_limit=2, period=1)
-        await self.mass.add_event_listener(self.mass_event, EVENT_PLAYBACK_STARTED)
+        await self.mass.add_event_listener(self.mass_event, EVENT_STREAM_STARTED)
         await self.mass.add_event_listener(self.mass_event, EVENT_PLAYBACK_STOPPED)
     
     async def search(self, searchstring, media_types=List[MediaType], limit=5):
@@ -283,7 +283,7 @@ class QobuzProvider(MusicProvider):
         if not self.__user_auth_info:
             return
         # TODO: need to figure out if the streamed track is purchased by user
-        if msg == EVENT_PLAYBACK_STARTED and msg_details["provider"] == self.prov_id:
+        if msg == EVENT_STREAM_STARTED and msg_details["provider"] == self.prov_id:
             # report streaming started to qobuz
             device_id = self.__user_auth_info["user"]["device"]["id"]
             credential_id = self.__user_auth_info["user"]["credential"]["id"]