1
0
mirror of https://github.com/hanxi/xiaomusic.git synced 2025-12-06 14:52:50 +08:00

fix: 优化登录问题

This commit is contained in:
涵曦
2025-11-01 10:02:48 +08:00
parent 7c8bde5808
commit 34d1aab7f5

View File

@@ -15,7 +15,7 @@ from dataclasses import asdict
from logging.handlers import RotatingFileHandler from logging.handlers import RotatingFileHandler
from aiohttp import ClientSession, ClientTimeout from aiohttp import ClientSession, ClientTimeout
from miservice import MiAccount, MiIOService, MiNAService from miservice import MiAccount, MiIOService, MiNAService, miio_command
from watchdog.events import ( from watchdog.events import (
FileCreatedEvent, FileCreatedEvent,
FileDeletedEvent, FileDeletedEvent,
@@ -32,6 +32,7 @@ from xiaomusic.config import (
Device, Device,
) )
from xiaomusic.const import ( from xiaomusic.const import (
TTS_COMMAND,
COOKIE_TEMPLATE, COOKIE_TEMPLATE,
GET_ASK_BY_MINA, GET_ASK_BY_MINA,
LATEST_ASK_API, LATEST_ASK_API,
@@ -1557,6 +1558,8 @@ class XiaoMusic:
device_list = await self.mina_service.device_list() device_list = await self.mina_service.device_list()
except Exception as e: except Exception as e:
self.log.warning(f"Execption {e}") self.log.warning(f"Execption {e}")
# 重新初始化
await self.xiaomusic.reinit()
return device_list return device_list
async def debug_play_by_music_url(self, arg1=None): async def debug_play_by_music_url(self, arg1=None):
@@ -2046,22 +2049,20 @@ class XiaoMusicDevice:
async def text_to_speech(self, value): async def text_to_speech(self, value):
try: try:
# 有 tts command 优先使用 tts command 说话 # 有 tts command 优先使用 tts command 说话
# if self.hardware in TTS_COMMAND: if self.hardware in TTS_COMMAND:
# tts_cmd = TTS_COMMAND[self.hardware] tts_cmd = TTS_COMMAND[self.hardware]
# self.log.info("Call MiIOService tts.") self.log.info("Call MiIOService tts.")
# value = value.replace(" ", ",") # 不能有空格 value = value.replace(" ", ",") # 不能有空格
# await miio_command( await miio_command(
# self.xiaomusic.miio_service, self.xiaomusic.miio_service,
# self.did, self.did,
# f"{tts_cmd} {value}", f"{tts_cmd} {value}",
# ) )
# else: else:
self.log.debug("Call MiNAService tts.") self.log.debug("Call MiNAService tts.")
await self.xiaomusic.mina_service.text_to_speech(self.device_id, value) await self.xiaomusic.mina_service.text_to_speech(self.device_id, value)
except Exception as e: except Exception as e:
self.log.exception(f"Execption {e}") self.log.exception(f"Execption {e}")
# 重新初始化
# await self.xiaomusic.reinit()
# 同一组设备播放 # 同一组设备播放
async def group_player_play(self, url, name=""): async def group_player_play(self, url, name=""):