rc-plugin/utils/biliInfo.js
RrOrange 1cd916d48f feat: 更改哔哩哔哩解析逻辑 & 🎈 perf: 提升论文解析速度
1. 增加bv av互转
2. 删除代码中的av逻辑,出现av一律转换为bv
3. 论文解析从race转换为any
2023-03-27 17:41:29 +08:00

24 lines
780 B
JavaScript

import fetch from "node-fetch";
async function getVideoInfo(url) {
const baseVideoInfo = "http://api.bilibili.com/x/web-interface/view";
const videoId = /video\/[^\?\/ ]+/.exec(url)[0].split("/")[1];
// 获取视频信息,然后发送
return fetch(`${baseVideoInfo}?bvid=${videoId}`)
.then(async resp => {
const respJson = await resp.json();
const respData = respJson.data;
return {
title: respData.title,
desc: respData.desc,
duration: respData.duration,
dynamic: respJson.data.dynamic,
stat: respData.stat,
aid: respData.aid,
cid: respData.pages?.[0].cid,
};
});
}
export { getVideoInfo };