mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-12-05 18:01:56 +00:00
✨ feat: 哔哩哔哩加入更多视频信息
This commit is contained in:
parent
1b5c187a47
commit
66d39246b9
@ -12,7 +12,7 @@ import HttpProxyAgent from "https-proxy-agent";
|
|||||||
import { mkdirsSync } from "../utils/file.js";
|
import { mkdirsSync } from "../utils/file.js";
|
||||||
import { downloadBFile, getDownloadUrl, mergeFileToMp4, getDynamic } from "../utils/bilibili.js";
|
import { downloadBFile, getDownloadUrl, mergeFileToMp4, getDynamic } from "../utils/bilibili.js";
|
||||||
import { parseUrl, parseM3u8, downloadM3u8Videos, mergeAcFileToMp4 } from "../utils/acfun.js";
|
import { parseUrl, parseM3u8, downloadM3u8Videos, mergeAcFileToMp4 } from "../utils/acfun.js";
|
||||||
import { transMap, douyinTypeMap } from "../utils/constant.js";
|
import { transMap, douyinTypeMap, TEN_THOUSAND } from "../utils/constant.js";
|
||||||
import { retry } from "../utils/common.js";
|
import { retry } from "../utils/common.js";
|
||||||
import config from "../model/index.js";
|
import config from "../model/index.js";
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ export class tools extends plugin {
|
|||||||
} else {
|
} else {
|
||||||
url = urlRex.exec(url)[0];
|
url = urlRex.exec(url)[0];
|
||||||
}
|
}
|
||||||
let idVideo = await this.getIdVideo(url)
|
let idVideo = await this.getIdVideo(url);
|
||||||
idVideo = idVideo.replace(/\//g, "");
|
idVideo = idVideo.replace(/\//g, "");
|
||||||
// API链接
|
// API链接
|
||||||
const API_URL = `https://api16-normal-c-useast1a.tiktokv.com/aweme/v1/feed/?aweme_id=${idVideo}&version_code=262&app_name=musical_ly&channel=App&device_id=null&os_version=14.4.2&device_platform=iphone&device_type=iPhone9`;
|
const API_URL = `https://api16-normal-c-useast1a.tiktokv.com/aweme/v1/feed/?aweme_id=${idVideo}&version_code=262&app_name=musical_ly&channel=App&device_id=null&os_version=14.4.2&device_platform=iphone&device_type=iPhone9`;
|
||||||
@ -339,13 +339,29 @@ export class tools extends plugin {
|
|||||||
videoId.startsWith("BV")
|
videoId.startsWith("BV")
|
||||||
? `${baseVideoInfo}?bvid=${videoId}`
|
? `${baseVideoInfo}?bvid=${videoId}`
|
||||||
: `${baseVideoInfo}?aid=${videoId}`,
|
: `${baseVideoInfo}?aid=${videoId}`,
|
||||||
)
|
).then(async resp => {
|
||||||
.then(resp => resp.json())
|
const respJson = await resp.json();
|
||||||
.then(resp => {
|
const respData = respJson.data;
|
||||||
e.reply(`识别:哔哩哔哩, ${resp.data.title}`).catch(err => {
|
// 视频标题
|
||||||
e.reply("解析失败,重试一下");
|
const title = "识别:哔哩哔哩," + respData.title + "\n";
|
||||||
console.log(err);
|
// 视频图片(暂时不加入,影响性能)
|
||||||
});
|
// const videoCover = respData.pic;
|
||||||
|
// 视频信息
|
||||||
|
let { view, danmaku, reply, favorite, coin, share, like } = respData.stat;
|
||||||
|
// 数据处理
|
||||||
|
const dataProcessing = data => {
|
||||||
|
return Number(data) >= TEN_THOUSAND ? (data / TEN_THOUSAND).toFixed(1) + "万" : data;
|
||||||
|
};
|
||||||
|
// 组合内容
|
||||||
|
const combineContent = `总播放量:${dataProcessing(
|
||||||
|
view,
|
||||||
|
)}, 弹幕数量:${dataProcessing(danmaku)}, 回复量:${dataProcessing(
|
||||||
|
reply,
|
||||||
|
)}, 收藏数:${dataProcessing(favorite)}, 投币:${dataProcessing(
|
||||||
|
coin,
|
||||||
|
)}, 分享:${dataProcessing(share)}, 点赞:${dataProcessing(like)}\n`;
|
||||||
|
const msgCombine = [title, combineContent/*, segment.image(videoCover)*/];
|
||||||
|
await e.reply(msgCombine);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@ -21,3 +21,5 @@ export const douyinTypeMap = {
|
|||||||
61: "video",
|
61: "video",
|
||||||
150: "image",
|
150: "image",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const TEN_THOUSAND = 10000;
|
||||||
Loading…
x
Reference in New Issue
Block a user