fix: 登陆失败不阻塞启动

This commit is contained in:
涵曦 2024-06-24 15:38:41 +00:00
parent 2d403ff18c
commit 7e2af515ed

View File

@ -143,27 +143,30 @@ class XiaoMusic:
self.miio_service = MiIOService(account) self.miio_service = MiIOService(account)
async def try_update_device_id(self): async def try_update_device_id(self):
hardware_data = await self.mina_service.device_list()
# fix multi xiaoai problems we check did first # fix multi xiaoai problems we check did first
# why we use this way to fix? # why we use this way to fix?
# some videos and articles already in the Internet # some videos and articles already in the Internet
# we do not want to change old way, so we check if miotDID in `env` first # we do not want to change old way, so we check if miotDID in `env` first
# to set device id # to set device id
for h in hardware_data: try:
if did := self.config.mi_did: hardware_data = await self.mina_service.device_list()
if h.get("miotDID", "") == str(did): for h in hardware_data:
if did := self.config.mi_did:
if h.get("miotDID", "") == str(did):
self.device_id = h.get("deviceID")
break
else:
continue
if h.get("hardware", "") == self.config.hardware:
self.device_id = h.get("deviceID") self.device_id = h.get("deviceID")
break break
else: else:
continue self.log.error(
if h.get("hardware", "") == self.config.hardware: f"we have no hardware: {self.config.hardware} please use `micli mina` to check"
self.device_id = h.get("deviceID") )
break except Exception:
else: pass
self.log.error(
f"we have no hardware: {self.config.hardware} please use `micli mina` to check"
)
async def _init_data_hardware(self): async def _init_data_hardware(self):
if self.config.cookie: if self.config.cookie: