调整json数据

This commit is contained in:
liuwei
2025-06-03 17:31:47 +08:00
parent f4105428a5
commit 62f2a4b8d6

View File

@@ -326,16 +326,12 @@ class GuessSongPlugin(MessagePluginInterface):
# 解析响应数据
json_data = response.json()
if not json_data.get("data") or json_data.get("code") != 200:
self.LOG.error(f"API 返回数据格式错误: {json_data}")
return {}
# 从歌曲列表中随机选择一首
song_list = json_data
if not song_list or not isinstance(song_list, list) or len(song_list) == 0:
self.LOG.error(f"未找到歌曲列表或列表为空")
return {}
self.LOG.debug(f"song_list:{song_list}")
# 随机选择一首歌曲
random_song = random.choice(song_list)
@@ -367,7 +363,7 @@ class GuessSongPlugin(MessagePluginInterface):
}
except Exception as e:
self.LOG.error(f"获取随机歌曲出错: {e}")
self.LOG.exception(f"获取随机歌曲出错: {e}")
return {}
async def _send_song_clip(self, bot: WechatAPIClient, song_info: Dict[str, Any], session_id: str) -> bool: