diff --git a/apps/tools.js b/apps/tools.js index 0814a03..6e02d9d 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -90,6 +90,8 @@ export class tools extends plugin { this.myProxy = `http://${this.proxyAddr}:${this.proxyPort}`; // 加载哔哩哔哩配置 this.biliSessData = this.toolsConfig.biliSessData; + // 加载哔哩哔哩的限制时长 + this.biliDuration = this.toolsConfig.biliDuration; // 加载gpt配置 this.openaiAccessToken = this.toolsConfig.openaiAccessToken; // 加载gpt客户端 @@ -326,6 +328,11 @@ export class tools extends plugin { // 请求视频信息 const videoInfo = await getVideoInfo(url); 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; // 数据处理 diff --git a/config/tools.yaml b/config/tools.yaml index 6d891f7..59cb909 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -6,4 +6,6 @@ translateAppId: '' # 百度翻译APP ID translateSecret: '' # 百度翻译密匙 biliSessData: '' # 哔哩哔哩的SESSDATA -openaiAccessToken: '' # 通过获取:https://chat.openai.com/api/auth/session +biliDuration: 900 # 哔哩哔哩限制的最大视频时长(默认15分钟),单位:秒 + +openaiAccessToken: '' # 通过获取:https://chat.openai.com/api/auth/session \ No newline at end of file diff --git a/guoba.support.js b/guoba.support.js index bb39c3b..9a104e2 100644 --- a/guoba.support.js +++ b/guoba.support.js @@ -86,6 +86,17 @@ export function supportGuoba() { placeholder: "请输入哔哩哔哩SESSDATA", }, }, + { + field: "tools.biliDuration", + label: "哔哩哔哩的视频最大限制时长", + bottomHelpMessage: + "超过时长无法解析,保护服务器性能", + component: "Input", + required: false, + componentProps: { + placeholder: "请输入哔哩哔哩的视频最大限制时长(默认15分钟)", + }, + }, { field: "tools.openaiAccessToken", label: "OpenAI的AccessToken",