From dc99681e1b16913936ca0e854e0b197461f5ab93 Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Sun, 12 Mar 2023 13:26:30 +0800 Subject: [PATCH] =?UTF-8?q?=E2=86=A9=20revert:=20=E9=80=80=E5=9B=9E?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 6a6eaec..36b27e7 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -644,26 +644,7 @@ export class tools extends plugin { async netease(e) { const message = e.msg === undefined ? e.message.shift().data.replaceAll("\\", "") : e.msg.trim(); const musicUrlReg = /(http:|https:)\/\/music.163.com\/song\/media\/outer\/url\?id=(\d+)/; - // 如果存在直接内容 - const musicJson = JSON.parse(message) - const {musicUrl, preview, title, desc} = musicJson.meta.music - // 如果没有下载地址跳出if - if (_.isNull(musicUrl) || _.isUndefined(musicUrl)) { - e.reply(`识别:网易云音乐,官方解析失败,开始执行第三方解析!`); - } else { - // 反之解析官方地址 - e.reply([`识别:网易云音乐,${title}--${desc}`, segment.image(preview)]); - await this.downloadMp3(musicUrl, 'follow').then(path => { - Bot.acquireGfs(e.group_id).upload(fs.readFileSync(path), '/', `${title.replace(/[\/\?<>\\:\*\|".… ]/g, '')}.mp3`) - }) - .catch(err => { - console.error(`下载音乐失败,错误信息为: ${err.message}`); - }); - // 中断后续执行 - return true; - } - // 不存在直接内容,通过第三方api获取 - const id = /id=(\d+)/.exec(message)[1]; + const id = musicUrlReg.exec(message)[2] || /id=(\d+)/.exec(message)[1]; fetch(`https://api.vvhan.com/api/music?id=${id}&type=song&media=netease`, { headers: { "User-Agent":