diff --git a/requirements.txt b/requirements.txt index 2713096..7332caf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,18 +6,21 @@ nonebot2[websockets] sqlalchemy~=2.0.34 autopep8 +graiax-silkcoder[ffmpeg] +Crypto~=1.4.1 graiax-silkcoder -graiax-silkcoder[ffempeg] Crypto fake_useragent -pycryptodome -PyExecJS +pycryptodome~=3.21.0 +PyExecJS~=1.5.1 gradio_client -requests~=2.32.3 -pillow~=10.4.0 +requests~=2.31.0 +pillow~=11.1.0 yaml~=0.2.5 -pyyaml~=6.0.1 \ No newline at end of file +pyyaml~=6.0.1 +qrcode~=7.4.2 +nonebot~=1.9.1 \ No newline at end of file diff --git a/src/music/cloud_music/cloud_music.py b/src/music/cloud_music/cloud_music.py index d3f7a7b..599c0d3 100644 --- a/src/music/cloud_music/cloud_music.py +++ b/src/music/cloud_music/cloud_music.py @@ -150,7 +150,7 @@ def netease_music_search(keyword,session): params = { "s": keyword, "type": 1, # 1 表示搜索歌曲,2 表示搜索专辑,3 表示搜索歌手等 - "limit": 50, # 限制搜索结果的数量 + "limit": 10, # 限制搜索结果的数量 "offset": 0, # 搜索结果的偏移量,可用于分页 "sub": "false", } @@ -161,6 +161,8 @@ def netease_music_search(keyword,session): if songs: filtered_data = [item for item in songs if item.get('fee') == 8]# 过滤掉付费歌曲 num = 0 + if len(filtered_data) - 1 <= 0: # 判断返回内容是否为空 + return None, None, None, None num = Random().randint(0, len(filtered_data) - 1) first_song = filtered_data[num] # 获取第一首歌曲 song_name = first_song["name"] diff --git a/src/qq_plugins/cloudMusic.py b/src/qq_plugins/cloudMusic.py index 89b1bf8..8f5e622 100644 --- a/src/qq_plugins/cloudMusic.py +++ b/src/qq_plugins/cloudMusic.py @@ -44,9 +44,9 @@ async def handle_function(msg: MessageEvent): #搜索歌曲 song_id,song_name,singer,song_url = netease_music_search(keyword,session) if song_id is None: - await music.finish("没有找到歌曲") + await music.finish("\n没有找到歌曲,或检索到的歌曲均为付费喔qwq\n这绝对不是我的错,绝对不是!") else: - await music.send(MessageSegment.text(f" 来源:网易云音乐\n歌曲:{song_name} - {singer}")) + await music.send(MessageSegment.text(f" 来源:网易云音乐\n歌曲:{song_name} - {singer}\n请稍等喔🎵\n\n注意:PC端QQ可能会出现无法播放情况,建议使用移动端")) #返回转换后的歌曲路径 output_silk_path = netease_music_download(song_id, song_name, singer,session) await music.send(MessageSegment.file_audio(Path(output_silk_path)))