Skip to content

Commit

Permalink
fix: 登陆失败不阻塞启动
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Jun 24, 2024
1 parent 2d403ff commit 7e2af51
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions xiaomusic/xiaomusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,30 @@ async def login_miboy(self, session):
self.miio_service = MiIOService(account)

async def try_update_device_id(self):
hardware_data = await self.mina_service.device_list()
# fix multi xiaoai problems we check did first
# why we use this way to fix?
# some videos and articles already in the Internet
# we do not want to change old way, so we check if miotDID in `env` first
# to set device id

for h in hardware_data:
if did := self.config.mi_did:
if h.get("miotDID", "") == str(did):
try:
hardware_data = await self.mina_service.device_list()
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")
break
else:
continue
if h.get("hardware", "") == self.config.hardware:
self.device_id = h.get("deviceID")
break
else:
self.log.error(
f"we have no hardware: {self.config.hardware} please use `micli mina` to check"
)
else:
self.log.error(
f"we have no hardware: {self.config.hardware} please use `micli mina` to check"
)
except Exception:
pass

async def _init_data_hardware(self):
if self.config.cookie:
Expand Down

0 comments on commit 7e2af51

Please sign in to comment.