Handle non-UTF8 .lrc files gracefully to prevent playback blocking (#2640)
authorOzGav <gavnosp@hotmail.com>
Sun, 16 Nov 2025 19:15:09 +0000 (05:15 +1000)
committerGitHub <noreply@github.com>
Sun, 16 Nov 2025 19:15:09 +0000 (20:15 +0100)
music_assistant/providers/filesystem_local/__init__.py

index 500cf57924d9fd29eef40196ba5168fd296310d1..cb786c29ebde426bddb20e021c4f9be2b5a32395 100644 (file)
@@ -995,8 +995,15 @@ class LocalFileSystemProvider(MusicProvider):
         assert file_item.ext is not None  # for type checking
         lrc_path = f"{file_item.absolute_path.removesuffix(file_item.ext)}lrc"
         if await self.exists(lrc_path):
-            async with aiofiles.open(lrc_path) as lrc_file:
-                track.metadata.lrc_lyrics = await lrc_file.read()
+            try:
+                async with aiofiles.open(lrc_path, encoding="utf-8") as lrc_file:
+                    track.metadata.lrc_lyrics = await lrc_file.read()
+            except Exception as err:
+                self.logger.warning(
+                    "Failed to read lyrics file %s: %s",
+                    lrc_path,
+                    str(err),
+                )
 
         return track