diff --git a/newpatch.sh b/newpatch.sh old mode 100755 new mode 100644 diff --git a/newversion.sh b/newversion.sh old mode 100755 new mode 100644 diff --git a/update-holiday.sh b/update-holiday.sh old mode 100755 new mode 100644 diff --git a/update-static-version.py b/update-static-version.py old mode 100755 new mode 100644 diff --git a/xiaomusic/auth.py b/xiaomusic/auth.py index 0822238..9c425c7 100644 --- a/xiaomusic/auth.py +++ b/xiaomusic/auth.py @@ -124,6 +124,12 @@ class AuthManager: self.login_acount = self.config.account self.login_password = self.config.password self.log.info(f"登录完成. {self.login_acount}") + except KeyError as e: + self.mina_service = None + self.miio_service = None + self.log.warning( + f"登录失败,API响应格式错误: {e}。建议使用Cookie登录或访问小米官网验证" + ) except Exception as e: self.mina_service = None self.miio_service = None @@ -148,15 +154,15 @@ class AuthManager: name = h.get("alias", "") if not name: name = h.get("name", "未知名字") - if device_id and hardware and did and (did in mi_dids): - device = self.config.devices.get(did, Device()) - device.did = did - # 将did存一下 方便其他地方调用 - self._cur_did = did - device.device_id = device_id - device.hardware = hardware - device.name = name - devices[did] = device + if device_id and hardware and did: + if not mi_dids or not mi_dids[0] or (did in mi_dids): + device = self.config.devices.get(did, Device()) + device.did = did + self._cur_did = did + device.device_id = device_id + device.hardware = hardware + device.name = name + devices[did] = device self.config.devices = devices self.log.info(f"选中的设备: {devices}") return devices diff --git a/xiaomusic/command_handler.py b/xiaomusic/command_handler.py index cabdd01..d613580 100644 --- a/xiaomusic/command_handler.py +++ b/xiaomusic/command_handler.py @@ -63,6 +63,9 @@ class CommandHandler: await device.check_replay() return + # 执行命令前先停止小爱,避免播放"不支持"提示 + await device.group_force_stop_xiaoai() + # 执行命令 func = getattr(self.xiaomusic, opvalue) await func(did=did, arg1=oparg)