mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00

1. 新增哔哩哔哩音乐提取,使用“bili音乐+链接”即可提取视频中的音乐 2. 重构部分代码 3. 更换tiktok API 4. 更换视频总结方式GPT为官方的视频摘要(免费使用) 5. 删除GPT相关内容
58 lines
2.0 KiB
JavaScript
58 lines
2.0 KiB
JavaScript
import fetch from "node-fetch";
|
|
import axios from "axios";
|
|
import { BILI_VIDEO_INFO } from "../constants/bili.js";
|
|
|
|
async function getVideoInfo(url) {
|
|
// const baseVideoInfo = "http://api.bilibili.com/x/web-interface/view";
|
|
const videoId = /video\/[^\?\/ ]+/.exec(url)[0].split("/")[1];
|
|
// 获取视频信息,然后发送
|
|
return fetch(`${BILI_VIDEO_INFO}?bvid=${videoId}`)
|
|
.then(async resp => {
|
|
const respJson = await resp.json();
|
|
const respData = respJson.data;
|
|
return {
|
|
title: respData.title,
|
|
pic: respData.pic,
|
|
desc: respData.desc,
|
|
duration: respData.duration,
|
|
dynamic: respJson.data.dynamic,
|
|
stat: respData.stat,
|
|
bvid: respData.bvid,
|
|
aid: respData.aid,
|
|
cid: respData.pages?.[0].cid,
|
|
owner: respData.owner,
|
|
pages: respData?.pages,
|
|
};
|
|
});
|
|
}
|
|
|
|
async function getDynamic(dynamicId) {
|
|
const dynamicApi = `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail?dynamic_id=${dynamicId}`
|
|
return axios.get(dynamicApi, {
|
|
headers: {
|
|
'User-Agent':
|
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36',
|
|
'referer': 'https://www.bilibili.com',
|
|
}
|
|
}).then(resp => {
|
|
const dynamicData = resp.data.data.card
|
|
const card = JSON.parse(dynamicData.card)
|
|
const dynamicOrigin = card.item
|
|
const dynamicDesc = dynamicOrigin.description
|
|
|
|
const pictures = dynamicOrigin.pictures
|
|
let dynamicSrc = []
|
|
for (let pic of pictures) {
|
|
const img_src = pic.img_src
|
|
dynamicSrc.push(img_src)
|
|
}
|
|
// console.log(dynamic_src)
|
|
return {
|
|
dynamicSrc,
|
|
dynamicDesc
|
|
}
|
|
})
|
|
}
|
|
|
|
export { getVideoInfo, getDynamic };
|