From 94f1a271388395277e7911148b5a0815c512790d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=8C=E8=8E=9E=7E=28=3D=5E=E2=96=BD=5E=3D=29?= Date: Tue, 10 Dec 2024 15:34:31 +0800 Subject: [PATCH] fix: empty manufacturer lead to failed parse_device_properties --- androidtv/basetv/basetv.py | 10 ++++++++-- androidtv/constants.py | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/androidtv/basetv/basetv.py b/androidtv/basetv/basetv.py index 50bfecb0..70382094 100644 --- a/androidtv/basetv/basetv.py +++ b/androidtv/basetv/basetv.py @@ -439,11 +439,17 @@ def _parse_device_properties(self, properties): return lines = properties.strip().splitlines() - if len(lines) != 5: + if len(lines) != 7: + _LOGGER.warning( + "%s:%d `get_device_properties` Invalid response length: %s", + self.host, + self.port, + properties, + ) self.device_properties = {} return - manufacturer, model, serialno, version, product_id = lines + _, manufacturer, model, serialno, version, product_id, _ = lines if not serialno.strip(): _LOGGER.warning( diff --git a/androidtv/constants.py b/androidtv/constants.py index 6fa36bb3..bcfeabc9 100644 --- a/androidtv/constants.py +++ b/androidtv/constants.py @@ -257,6 +257,7 @@ class DeviceEnum(IntEnum): CMD_SERIALNO = "getprop ro.serialno" CMD_VERSION = "getprop ro.build.version.release" CMD_PRODUCT_ID = "getprop ro.product.vendor.device" +CMD_ECHO_PLACEHOLDER = "echo %" # Commands for getting the MAC address CMD_MAC_WLAN0 = "ip addr show wlan0 | grep -m 1 ether" @@ -264,7 +265,7 @@ class DeviceEnum(IntEnum): #: The command used for getting the device properties CMD_DEVICE_PROPERTIES = ( - CMD_MANUFACTURER + " && " + CMD_MODEL + " && " + CMD_SERIALNO + " && " + CMD_VERSION + " && " + CMD_PRODUCT_ID + CMD_ECHO_PLACEHOLDER + " && " + CMD_MANUFACTURER + " && " + CMD_MODEL + " && " + CMD_SERIALNO + " && " + CMD_VERSION + " && " + CMD_PRODUCT_ID + " && " + CMD_ECHO_PLACEHOLDER )