mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🎈 perf: 优化哔哩哔哩信息排榜,更美观!
This commit is contained in:
parent
5bbef5ef8a
commit
65f85fd821
@ -330,21 +330,18 @@ export class tools extends plugin {
|
|||||||
// 视频信息获取例子:http://api.bilibili.com/x/web-interface/view?bvid=BV1hY411m7cB
|
// 视频信息获取例子:http://api.bilibili.com/x/web-interface/view?bvid=BV1hY411m7cB
|
||||||
// 请求视频信息
|
// 请求视频信息
|
||||||
const videoInfo = await getVideoInfo(url);
|
const videoInfo = await getVideoInfo(url);
|
||||||
const { title, desc, duration, dynamic, stat, aid, cid, pages } = videoInfo;
|
const { title, pic, desc, duration, dynamic, stat, aid, cid, pages } = videoInfo;
|
||||||
// 限制时长 & 考虑分页视频情况
|
|
||||||
const query = querystring.parse(url);
|
|
||||||
const curPage = query?.p || 0;
|
|
||||||
const curDuration = pages?.[curPage].duration || duration;
|
|
||||||
if (curDuration > this.biliDuration) {
|
|
||||||
e.reply(`当前视频时长约:${(pages?.[curPage].duration / 60).toFixed(0)}分钟,\n大于管理员设置的最大时长 ${this.biliDuration / 60} 分钟!`);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// 视频信息
|
// 视频信息
|
||||||
let { view, danmaku, reply, favorite, coin, share, like } = stat;
|
let { view, danmaku, reply, favorite, coin, share, like } = stat;
|
||||||
// 数据处理
|
// 数据处理
|
||||||
const dataProcessing = data => {
|
const dataProcessing = data => {
|
||||||
return Number(data) >= TEN_THOUSAND ? (data / TEN_THOUSAND).toFixed(1) + "万" : data;
|
return Number(data) >= TEN_THOUSAND ? (data / TEN_THOUSAND).toFixed(1) + "万" : data;
|
||||||
};
|
};
|
||||||
|
// 限制时长 & 考虑分页视频情况
|
||||||
|
const query = querystring.parse(url);
|
||||||
|
const curPage = query?.p || 0;
|
||||||
|
const curDuration = pages?.[curPage].duration || duration;
|
||||||
|
const isLimitDuration = curDuration > this.biliDuration
|
||||||
// 格式化数据
|
// 格式化数据
|
||||||
const combineContent =
|
const combineContent =
|
||||||
`\n点赞:${dataProcessing(like)} | 硬币:${dataProcessing(
|
`\n点赞:${dataProcessing(like)} | 硬币:${dataProcessing(
|
||||||
@ -354,7 +351,16 @@ export class tools extends plugin {
|
|||||||
danmaku,
|
danmaku,
|
||||||
)} | 评论:${dataProcessing(reply)}\n` +
|
)} | 评论:${dataProcessing(reply)}\n` +
|
||||||
`简介:${desc}`;
|
`简介:${desc}`;
|
||||||
e.reply([`识别:哔哩哔哩:${title}`, combineContent]);
|
let biliInfo = [`识别:哔哩哔哩:${title}`, combineContent]
|
||||||
|
if (isLimitDuration) {
|
||||||
|
biliInfo.unshift(segment.image(pic))
|
||||||
|
const durationInMinutes = (pages?.[curPage].duration / 60).toFixed(0);
|
||||||
|
biliInfo.push(`\n-----------------------限制说明-----------------------\n当前视频时长约:${durationInMinutes}分钟,\n大于管理员设置的最大时长 ${this.biliDuration / 60} 分钟!`)
|
||||||
|
e.reply(biliInfo);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
e.reply(biliInfo);
|
||||||
|
}
|
||||||
|
|
||||||
// 创建文件,如果不存在
|
// 创建文件,如果不存在
|
||||||
const path = `${this.defaultPath}${this.e.group_id || this.e.user_id}/`;
|
const path = `${this.defaultPath}${this.e.group_id || this.e.user_id}/`;
|
||||||
|
@ -11,6 +11,7 @@ async function getVideoInfo(url) {
|
|||||||
const respData = respJson.data;
|
const respData = respJson.data;
|
||||||
return {
|
return {
|
||||||
title: respData.title,
|
title: respData.title,
|
||||||
|
pic: respData.pic,
|
||||||
desc: respData.desc,
|
desc: respData.desc,
|
||||||
duration: respData.duration,
|
duration: respData.duration,
|
||||||
dynamic: respJson.data.dynamic,
|
dynamic: respJson.data.dynamic,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user