🐞 fix: 修复波点音乐如果没有信息没返回的问题

This commit is contained in:
zhiyu1998 2023-03-20 09:03:06 +08:00
parent 20ec59ce5f
commit c25421ebda

View File

@ -647,15 +647,12 @@ export class tools extends plugin {
const API = `https://xiaobai.klizi.cn/API/music/bodian.php?msg=${msg}&n=&max=`; const API = `https://xiaobai.klizi.cn/API/music/bodian.php?msg=${msg}&n=&max=`;
// 获取列表 // 获取列表
const thisMethod = this; const thisMethod = this;
await axios.get(API).then(resp => { await axios.get(API, {
/** headers: {
* "songName": "山海", "HOST": "xiaobai.klizi.cn",
* "artist": "草东没有派对", "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",
* "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", }).then(resp => {
* "lowUrl": "http://other.player.nf03.sycdn.kuwo.cn/47e753a5f8350140716e439f1c87dc1f/64172260/resource/m3/50/96/2318372432.mp4?from=bodian",
* "shortLowUrl": null
*/
e.reply("请选择一个要播放的视频:\n" + resp.data); e.reply("请选择一个要播放的视频:\n" + resp.data);
thisMethod.setContext("bodianMusicContext"); thisMethod.setContext("bodianMusicContext");
}); });
@ -676,10 +673,22 @@ export class tools extends plugin {
curMsg.msg, curMsg.msg,
)}&max=`; )}&max=`;
const thisMethod = this; 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 { try {
// 波点音乐信息
const { songName, artist, coverUrl, highUrl, lowUrl, shortLowUrl } = res.data; const { songName, artist, coverUrl, highUrl, lowUrl, shortLowUrl } = res.data;
curMsg.reply([`${songName}-${artist}\n`, segment.image(coverUrl)]); curMsg.reply([`${songName}-${artist}\n`, segment.image(coverUrl)]);
// 下载 && 发送
await thisMethod.downloadVideo(lowUrl).then(path => { await thisMethod.downloadVideo(lowUrl).then(path => {
curMsg.reply(segment.video(path + "/temp.mp4")); curMsg.reply(segment.video(path + "/temp.mp4"));
}); });