From c25421ebda7fae58e4405f7cbe0ec76a33f7aadf Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Mon, 20 Mar 2023 09:03:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B3=A2=E7=82=B9=E9=9F=B3=E4=B9=90=E5=A6=82=E6=9E=9C=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E4=BF=A1=E6=81=AF=E6=B2=A1=E8=BF=94=E5=9B=9E=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 --- apps/tools.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index ca12d3c..936f41a 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -647,15 +647,12 @@ export class tools extends plugin { const API = `https://xiaobai.klizi.cn/API/music/bodian.php?msg=${msg}&n=&max=`; // 获取列表 const thisMethod = this; - await axios.get(API).then(resp => { - /** - * "songName": "山海", - * "artist": "草东没有派对", - * "coverUrl": "https://img3.kuwo.cn/wmvpic/324/78/55/3196258119.jpg", - * "highUrl": "http://other.player.nf03.sycdn.kuwo.cn/f7451ba7f02256b6b5d5ae8a74336502/64172260/resource/m2/55/56/3401786858.mp4?from=bodian", - * "lowUrl": "http://other.player.nf03.sycdn.kuwo.cn/47e753a5f8350140716e439f1c87dc1f/64172260/resource/m3/50/96/2318372432.mp4?from=bodian", - * "shortLowUrl": null - */ + await axios.get(API, { + headers: { + "HOST": "xiaobai.klizi.cn", + "User-Agent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36", + } + }).then(resp => { e.reply("请选择一个要播放的视频:\n" + resp.data); thisMethod.setContext("bodianMusicContext"); }); @@ -676,10 +673,22 @@ export class tools extends plugin { curMsg.msg, )}&max=`; const thisMethod = this; - axios.get(API).then(async res => { + axios.get(API, { + headers: { + "HOST": "xiaobai.klizi.cn", + "User-Agent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36", + } + }).then(async res => { + // 如果没有,直接返回 + if (res.data.lowUrl === null || res.data.highUrl === null) { + return; + } + // 捕获一些未知错误 try { + // 波点音乐信息 const { songName, artist, coverUrl, highUrl, lowUrl, shortLowUrl } = res.data; curMsg.reply([`${songName}-${artist}\n`, segment.image(coverUrl)]); + // 下载 && 发送 await thisMethod.downloadVideo(lowUrl).then(path => { curMsg.reply(segment.video(path + "/temp.mp4")); });