From 1eeaa793a128930ecf2a236ec9fb61b5ea23e824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Sun, 9 Mar 2025 16:56:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=90=8E=E4=B8=8D=E8=87=AA=E5=8A=A8=E6=92=AD=E6=94=BE=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/config.py | 2 +- xiaomusic/httpserver.py | 2 +- xiaomusic/static/default/setting.html | 2 +- xiaomusic/static/index.html | 2 +- xiaomusic/utils.py | 22 +++++++++++++--------- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/xiaomusic/config.py b/xiaomusic/config.py index 96e8746..5089226 100644 --- a/xiaomusic/config.py +++ b/xiaomusic/config.py @@ -316,7 +316,7 @@ class Config: @property def tag_cache_path(self): - if not os.path.exists(self.cache_dir): + if (len(self.cache_dir) > 0) and (not os.path.exists(self.cache_dir)): os.makedirs(self.cache_dir) filename = os.path.join(self.cache_dir, "tag_cache.json") return filename diff --git a/xiaomusic/httpserver.py b/xiaomusic/httpserver.py index 7cd8035..421eac6 100644 --- a/xiaomusic/httpserver.py +++ b/xiaomusic/httpserver.py @@ -151,7 +151,7 @@ async def custom_event(sid, data): await sio.emit("response", {"action": "切歌", "status": data}) -@app.post("thdaction") +@app.post("/thdaction") async def thdaction(item: Item): await sio.emit( "response", diff --git a/xiaomusic/static/default/setting.html b/xiaomusic/static/default/setting.html index fea201c..7d54200 100644 --- a/xiaomusic/static/default/setting.html +++ b/xiaomusic/static/default/setting.html @@ -97,7 +97,7 @@ var vConsole = new window.VConsole(); - + diff --git a/xiaomusic/static/index.html b/xiaomusic/static/index.html index fb64e10..1e0a7f7 100644 --- a/xiaomusic/static/index.html +++ b/xiaomusic/static/index.html @@ -52,7 +52,7 @@ 怀旧主题
- Tailwind主题 + Tailwind
Pure主题 diff --git a/xiaomusic/utils.py b/xiaomusic/utils.py index 2158871..fcd3e4c 100644 --- a/xiaomusic/utils.py +++ b/xiaomusic/utils.py @@ -241,15 +241,19 @@ async def thdplay( ): # 接口地址 target,在参数文件指定 data = {"action": action, "args": args} - async with aiohttp.ClientSession() as session: - async with session.post( - target, json=data, timeout=5 - ) as response: # 增加超时以避免长时间挂起 - # 如果响应不是200,引发异常 - response.raise_for_status() - # 读取响应文本 - text = await response.text() - return "[]" not in text + try: + async with aiohttp.ClientSession() as session: + async with session.post( + target, json=data, timeout=5 + ) as response: # 增加超时以避免长时间挂起 + # 如果响应不是200,引发异常 + response.raise_for_status() + # 读取响应文本 + text = await response.text() + return "[]" not in text + except Exception as e: + log.error(f"Error _get_web_music_duration: {e}") + return False async def downloadfile(url):