From e8151c39383ab40d3ad820a90b2cb538555372a7 Mon Sep 17 00:00:00 2001 From: Carmine Cristallo <5416417+ccristal@users.noreply.github.com> Date: Sun, 18 Oct 2026 15:48:42 +0100 Subject: [PATCH 1/2] Return an empty album_art when the device reports a placeholder LinkPlay/WiiM devices report missing album art as the string "unknow" in getMetaInfo. album_art passed it through unchanged, so consumers treated it as an image URL. Only return http(s) URLs and an empty string otherwise. Fixes #137 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DBuBhcANHioWShtwB1sTxq --- src/linkplay/bridge.py | 8 ++++++-- tests/linkplay/test_bridge.py | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/linkplay/bridge.py b/src/linkplay/bridge.py index 0f6e5f3..68d49b4 100644 --- a/src/linkplay/bridge.py +++ b/src/linkplay/bridge.py @@ -333,10 +333,14 @@ def album(self) -> str: @property def album_art(self) -> str: - """Returns the url to the album art.""" - return self.metainfo.get(MetaInfo.METADATA, {}).get( + """Returns the url to the album art, or an empty string if there is none.""" + album_art = self.metainfo.get(MetaInfo.METADATA, {}).get( MetaInfoMetaData.ALBUM_ART, "" ) + # Devices report missing album art as a placeholder such as "unknow" + if not album_art.startswith(("http://", "https://")): + return "" + return album_art @property def volume(self) -> int: diff --git a/tests/linkplay/test_bridge.py b/tests/linkplay/test_bridge.py index 100a8f1..afb9d6c 100644 --- a/tests/linkplay/test_bridge.py +++ b/tests/linkplay/test_bridge.py @@ -17,6 +17,8 @@ EqualizerMode, LinkPlayCommand, LoopMode, + MetaInfo, + MetaInfoMetaData, MuteMode, PlayerAttribute, PlayingMode, @@ -602,6 +604,31 @@ async def mock_session_call_api_json_side_effect(endpoint, session, command): mock_api.assert_called_with("http://1.2.3.4", None, LinkPlayCommand.META_INFO) + +@pytest.mark.parametrize( + ("album_art_uri", "expected"), + [ + ("https://example.com/cover.jpg", "https://example.com/cover.jpg"), + ("http://example.com/cover.jpg", "http://example.com/cover.jpg"), + ("unknow", ""), + ("", ""), + ], +) +def test_album_art(album_art_uri: str, expected: str): + """Test that only http(s) album art urls are returned.""" + player = LinkPlayPlayer(MagicMock()) + player.metainfo = {MetaInfo.METADATA: {MetaInfoMetaData.ALBUM_ART: album_art_uri}} + + assert player.album_art == expected + + +def test_album_art_without_metainfo(): + """Test that the album art is empty when no meta info is available.""" + player = LinkPlayPlayer(MagicMock()) + player.metainfo = {} + + assert player.album_art == "" + async def test_audio_output_control(): """Test that the player handles a audio output control correctly.""" From 44227bf79eee39d805351f55f6891066fd463dca Mon Sep 17 00:00:00 2001 From: Carmine Cristallo <5416417+ccristal@users.noreply.github.com> Date: Mon, 19 Oct 2026 20:29:43 +0100 Subject: [PATCH 2/2] Fix blank lines around the album_art tests Co-Authored-By: Claude Opus 5.5 --- tests/linkplay/test_bridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/linkplay/test_bridge.py b/tests/linkplay/test_bridge.py index afb9d6c..3415bba 100644 --- a/tests/linkplay/test_bridge.py +++ b/tests/linkplay/test_bridge.py @@ -604,7 +604,6 @@ async def mock_session_call_api_json_side_effect(endpoint, session, command): mock_api.assert_called_with("http://1.2.3.4", None, LinkPlayCommand.META_INFO) - @pytest.mark.parametrize( ("album_art_uri", "expected"), [ @@ -629,6 +628,7 @@ def test_album_art_without_metainfo(): assert player.album_art == "" + async def test_audio_output_control(): """Test that the player handles a audio output control correctly."""