From 87aac590e411d165b57d31941f9da340e2be76e4 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Mon, 8 Dec 2025 00:51:35 +0100 Subject: [PATCH] Tweak for spotify streamer --- .../providers/spotify/streaming.py | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/music_assistant/providers/spotify/streaming.py b/music_assistant/providers/spotify/streaming.py index bb8bf746..6c2b824f 100644 --- a/music_assistant/providers/spotify/streaming.py +++ b/music_assistant/providers/spotify/streaming.py @@ -81,27 +81,18 @@ class LibrespotStreamer: log_history.append(line) if "ERROR" in line or "WARNING" in line: logger.warning("[librespot] %s", line) + if "Unable to read audio file" in line: + # if this happens, we should stop the process to avoid hanging + await librespot_proc.close() else: logger.log(VERBOSE_LOG_LEVEL, "[librespot] %s", line) librespot_proc.attach_stderr_reader(asyncio.create_task(log_librespot_output())) + # yield from librespot's stdout + async for chunk in librespot_proc.iter_chunked(): + yield chunk - try: - # yield from librespot's stdout - async for chunk in librespot_proc.iter_chunked(): - yield chunk - - if librespot_proc.returncode != 0: - raise AudioError( - f"Librespot exited with code {librespot_proc.returncode} for {spotify_uri}" - ) - - except Exception as ex: - log_lines_str = "\n".join(log_history) - logger.error( - "Librespot streaming error for %s: %s\n%s", - spotify_uri, - ex, - log_lines_str, + if librespot_proc.returncode != 0: + raise AudioError( + f"Librespot exited with code {librespot_proc.returncode} for {spotify_uri}" ) - raise AudioError(f"Error streaming from librespot for {spotify_uri}: {ex}") from ex -- 2.34.1