🎈 perf: 优化哔哩哔哩解析存在的一些问题

This commit is contained in:
zhiyu1998 2023-02-12 01:05:22 +08:00
parent e6f58cbf27
commit 624941054e

View File

@ -182,15 +182,21 @@ export class tools extends plugin {
mkdirsSync(path); mkdirsSync(path);
} }
// 视频信息获取例子http://api.bilibili.com/x/web-interface/view?bvid=BV1hY411m7cB // 视频信息获取例子http://api.bilibili.com/x/web-interface/view?bvid=BV1hY411m7cB
const baseVideoInfo = "http://api.bilibili.com/x/web-interface/view"; // 请求视频信息
console.log(url); (function() {
const videoId = /video\/(.*?)(\/|\?)/g.exec(url)[1]; const baseVideoInfo = "http://api.bilibili.com/x/web-interface/view";
// 获取视频信息,然后发送 const videoId = /video\/[^\?\/ ]+/.exec(url)[0].split("/")[1];
fetch(videoId.startsWith("BV") ? `${baseVideoInfo}?bvid=${videoId}` : `${baseVideoInfo}?aid=${videoId}`) // 获取视频信息,然后发送
.then(resp => resp.json()) fetch(videoId.startsWith("BV") ? `${baseVideoInfo}?bvid=${videoId}` : `${baseVideoInfo}?aid=${videoId}`)
.then(resp => { .then(resp => resp.json())
e.reply(`识别:哔哩哔哩, ${resp.data.title}`) .then(resp => {
e.reply(`识别:哔哩哔哩, ${resp.data.title}`)
.catch(err => {
e.reply("解析失败,重试一下");
console.log(err);
})
}) })
}())
await getDownloadUrl(url) await getDownloadUrl(url)
.then(data => { .then(data => {