some small tweaks
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Thu, 29 Aug 2024 18:00:12 +0000 (20:00 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Thu, 29 Aug 2024 18:00:12 +0000 (20:00 +0200)
music_assistant/server/controllers/streams.py
music_assistant/server/helpers/audio.py
music_assistant/server/providers/slimproto/__init__.py

index 6e4e36fe523fb0f3a0682932f06773057962f4a3..e35deaef2a6d13045b6291ecda8fbfeceb863972 100644 (file)
@@ -814,7 +814,7 @@ class StreamsController(CoreController):
             if streamdetails.media_type == MediaType.RADIO:
                 # ffmpeg sometimes has trouble with HLS radio streams stopping
                 # abruptly for no reason so this is a workaround to keep the stream alive
-                extra_input_args += ["-stream_loop", "-1"]
+                extra_input_args += ["-reconnect_at_eof", "1"]
         elif streamdetails.stream_type == StreamType.ENCRYPTED_HTTP:
             audio_source = streamdetails.path
             extra_input_args += ["-decryption_key", streamdetails.decryption_key]
index 63e3474fd72376e69d862fd12985ac553dda7b47..b5fb21044b9740260250bb6b930a169a75a4b289 100644 (file)
@@ -500,17 +500,17 @@ async def resolve_radio_stream(mass: MusicAssistant, url: str) -> tuple[str, boo
             or "audio/x-scpls" in headers.get("content-type", "")
         ):
             # url is playlist, we need to unfold it
-            substreams = await fetch_playlist(mass, url)
-            if not any(x for x in substreams if x.length):
-                try:
+            try:
+                substreams = await fetch_playlist(mass, url)
+                if not any(x for x in substreams if x.length):
                     for line in substreams:
                         if not line.is_url:
                             continue
                         # unfold first url of playlist
                         return await resolve_radio_stream(mass, line.path)
                     raise InvalidDataError("No content found in playlist")
-                except IsHLSPlaylist:
-                    is_hls = True
+            except IsHLSPlaylist:
+                is_hls = True
 
     except Exception as err:
         LOGGER.warning("Error while parsing radio URL %s: %s", url, err)
@@ -913,9 +913,9 @@ def get_ffmpeg_args(
             # these options are only supported in ffmpeg > 5
             input_args += [
                 "-reconnect_on_network_error",
-                "1",
+                "5",
                 "-reconnect_on_http_error",
-                "5xx",
+                "5xx,4xx",
             ]
     if input_format.content_type.is_pcm():
         input_args += [
index fbe5ae429ea4f7105e76ae73de40911e7897c036..f908529155ab7c35b80b5486d0939704649dd71f 100644 (file)
@@ -674,7 +674,9 @@ class SlimprotoProvider(PlayerProvider):
 
         # elapsed time change on the player will be auto picked up
         # by the player manager.
-        player = self.mass.players.get(slimplayer.player_id)
+        if not (player := self.mass.players.get(slimplayer.player_id)):
+            # race condition?!
+            return
         player.elapsed_time = slimplayer.elapsed_seconds
         player.elapsed_time_last_updated = time.time()