From 2d197ed096206449f0487e50068698796a6f2a93 Mon Sep 17 00:00:00 2001 From: Louis Christ Date: Thu, 4 Sep 2025 22:42:45 +0200 Subject: [PATCH] Fix input.text can be None --- src/pyblu/entities.py | 2 +- src/pyblu/parse.py | 2 +- tests/test_player.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pyblu/entities.py b/src/pyblu/entities.py index 9f60c77..90c5b54 100644 --- a/src/pyblu/entities.py +++ b/src/pyblu/entities.py @@ -157,7 +157,7 @@ class Preset: class Input: id: str | None """Unique id of the input""" - text: str + text: str | None """User friendly name of the input""" image: str """URL of the input image""" diff --git a/src/pyblu/parse.py b/src/pyblu/parse.py index 0b1f7d1..2e1082b 100644 --- a/src/pyblu/parse.py +++ b/src/pyblu/parse.py @@ -226,7 +226,7 @@ def parse_inputs(response: bytes) -> list[Input]: inputs = [ Input( id=x.attrib.get("id"), - text=x.attrib["text"], + text=x.attrib.get("text"), image=x.attrib["image"], url=unquote(x.attrib["URL"]), ) diff --git a/tests/test_player.py b/tests/test_player.py index 37248a4..edce908 100644 --- a/tests/test_player.py +++ b/tests/test_player.py @@ -638,6 +638,7 @@ async def test_inputs(): + """, ) @@ -650,6 +651,7 @@ async def test_inputs(): Input(id=None, text="Bluetooth", image="/images/BluetoothIcon.png", url="Capture:bluez:bluetooth"), Input(id="input2", text="HDMI ARC", image="/images/capture/ic_tv.png", url="Capture:hw:imxspdif,0/1/25/2?id=input2"), Input(id="Spotify", text="Spotify", image="/Sources/images/SpotifyIcon.png", url="Spotify:play"), + Input(id="xdynamic-Source7", text=None, image="/images/capture/ic_analoginput.png", url="Capture:hw:soundchassis,0/1/25/2?id=xdynamic-Source7"), ]