feat: 增加issue要求的哔哩哔哩解析视频时长限制(#I6O2OE)

This commit is contained in:
RrOrange 2023-04-07 22:05:05 +08:00
parent bb5caffb73
commit a032e7d9cf
3 changed files with 21 additions and 1 deletions

View File

@ -90,6 +90,8 @@ export class tools extends plugin {
this.myProxy = `http://${this.proxyAddr}:${this.proxyPort}`; this.myProxy = `http://${this.proxyAddr}:${this.proxyPort}`;
// 加载哔哩哔哩配置 // 加载哔哩哔哩配置
this.biliSessData = this.toolsConfig.biliSessData; this.biliSessData = this.toolsConfig.biliSessData;
// 加载哔哩哔哩的限制时长
this.biliDuration = this.toolsConfig.biliDuration;
// 加载gpt配置 // 加载gpt配置
this.openaiAccessToken = this.toolsConfig.openaiAccessToken; this.openaiAccessToken = this.toolsConfig.openaiAccessToken;
// 加载gpt客户端 // 加载gpt客户端
@ -326,6 +328,11 @@ export class tools extends plugin {
// 请求视频信息 // 请求视频信息
const videoInfo = await getVideoInfo(url); const videoInfo = await getVideoInfo(url);
const { title, desc, duration, dynamic, stat, aid, cid } = videoInfo; const { title, desc, duration, dynamic, stat, aid, cid } = videoInfo;
// 限制时长
if (duration > this.biliDuration) {
e.reply(`当前视频时长约:${(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;
// 数据处理 // 数据处理

View File

@ -6,4 +6,6 @@ translateAppId: '' # 百度翻译APP ID
translateSecret: '' # 百度翻译密匙 translateSecret: '' # 百度翻译密匙
biliSessData: '' # 哔哩哔哩的SESSDATA biliSessData: '' # 哔哩哔哩的SESSDATA
openaiAccessToken: '' # 通过获取https://chat.openai.com/api/auth/session biliDuration: 900 # 哔哩哔哩限制的最大视频时长默认15分钟单位
openaiAccessToken: '' # 通过获取https://chat.openai.com/api/auth/session

View File

@ -86,6 +86,17 @@ export function supportGuoba() {
placeholder: "请输入哔哩哔哩SESSDATA", placeholder: "请输入哔哩哔哩SESSDATA",
}, },
}, },
{
field: "tools.biliDuration",
label: "哔哩哔哩的视频最大限制时长",
bottomHelpMessage:
"超过时长无法解析,保护服务器性能",
component: "Input",
required: false,
componentProps: {
placeholder: "请输入哔哩哔哩的视频最大限制时长默认15分钟",
},
},
{ {
field: "tools.openaiAccessToken", field: "tools.openaiAccessToken",
label: "OpenAI的AccessToken", label: "OpenAI的AccessToken",