From afad8921cd8ad6dcca7c020de91a9d7e78077115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E5=88=80=E9=B1=BC?= <9903082+qdyovo@user.noreply.gitee.com> Date: Fri, 18 Oct 2024 10:41:27 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=8E=88pref=EF=BC=9A=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=B2=B9=E7=AE=A1=E8=A7=86=E9=A2=91=E8=A7=A3=E6=9E=90=E7=AD=96?= =?UTF-8?q?=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 31 ++++++++++++++++++++----------- config/tools.yaml | 7 ++++--- guoba.support.js | 19 +++++++++++++++---- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 1198248..8454aaf 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -281,10 +281,12 @@ export class tools extends plugin { this.biliDownloadMethod = this.toolsConfig.biliDownloadMethod; // 加载哔哩哔哩最高分辨率 this.biliResolution = this.toolsConfig.biliResolution; - // 加载youtube的限制时长 + // 加载youtube的截取时长 + this.youtubeClipTime = this.toolsConfig.youtubeClipTime + // 加载youtube的解析时长 this.youtubeDuration = this.toolsConfig.youtubeDuration // 加载油管下载画质选项 - this.YouTubeGraphicsOptions = this.toolsConfig.YouTubeGraphicsOptions + this.youtubeGraphicsOptions = this.toolsConfig.youtubeGraphicsOptions // 加载抖音Cookie this.douyinCookie = this.toolsConfig.douyinCookie; // 加载抖音是否压缩 @@ -1922,7 +1924,7 @@ export class tools extends plugin { // 构造时间范围字符串 return `00:00:00-${formattedHours}:${formattedMinutes}:${formattedSeconds}`; } - const timeRange = await formatTime(this.youtubeDuration) + const timeRange = await formatTime(this.youtubeClipTime) const isOversea = await this.isOverseasServer(); if (!isOversea && !(await testProxy(this.proxyAddr, this.proxyPort))) { e.reply("检测到没有梯子,无法解析油管"); @@ -1944,8 +1946,8 @@ export class tools extends plugin { let url = removeParams(urlRex.exec(e.msg)?.[0] || url2Rex.exec(e.msg)?.[0]).replace(/&/g, isWindows ? '^&' : '&') //非最高画质,就按照设定的来 let graphics = "" - if (this.YouTubeGraphicsOptions != 0) { - graphics = `[height<=${ this.YouTubeGraphicsOptions }]` + if (this.youtubeGraphicsOptions != 0) { + graphics = `[height<=${ this.youtubeGraphicsOptions }]` } // 适配 YouTube Music if (url.includes("music")) { @@ -1965,16 +1967,23 @@ export class tools extends plugin { } const Duration = convertToSeconds(await ytDlpGetDuration(url, isOversea, this.myProxy).toString().replace(/\n/g, '')) // logger.info('时长------',Duration) - if(Duration > this.youtubeDuration){ + if (Duration > this.youtubeDuration) { e.reply([ - segment.image(`${ path }/thumbnail.png`), - `${this.identifyPrefix}识别:油管,视频下载中请耐心等待 \n视频标题:${title}${DIVIDING_LINE.replace('{}', '限制说明')}\n视频时长:${(Duration / 60).toFixed(2).replace(/\.00$/, '')} 分钟\n大于管理员限定时长:${(this.youtubeDuration / 60).toFixed(2).replace(/\.00$/, '')} 分钟\n将截取限定时间部分` + segment.image(`${path}/thumbnail.png`), + `${this.identifyPrefix}识别:油管,视频时长超限 \n视频标题:${title}\n⌚${DIVIDING_LINE.replace('{}', '限制说明').replace(/\n/g, '')}⌚\n视频时长:${(Duration / 60).toFixed(2).replace(/\.00$/, '')} 分钟\n大于管理员限定解析时长:${(this.youtubeDuration / 60).toFixed(2).replace(/\.00$/, '')} 分钟` ]); + } else if (Duration > this.youtubeClipTime && timeRange != '00:00:00-00:00:00') { + e.reply([ + segment.image(`${path}/thumbnail.png`), + `${this.identifyPrefix}识别:油管,视频截取中请耐心等待 \n视频标题:${title}\n✂️${DIVIDING_LINE.replace('{}', '截取说明').replace(/\n/g, '')}✂️\n视频时长:${(Duration / 60).toFixed(2).replace(/\.00$/, '')} 分钟\n大于管理员限定截取时长:${(this.youtubeClipTime / 60).toFixed(2).replace(/\.00$/, '')} 分钟\n将截取视频片段` + ]); + await ytDlpHelper(path, url, isOversea, this.myProxy, this.videoDownloadConcurrency, true, graphics, timeRange); + this.sendVideoToUpload(e, `${path}/temp.mp4`); } else { - e.reply([segment.image(`${ path }/thumbnail.png`),`${ this.identifyPrefix }识别:油管,视频下载中请耐心等待 \n视频标题:${ title }\n视频时长:${(Duration / 60).toFixed(2).replace(/\.00$/, '')} 分钟`]); + e.reply([segment.image(`${path}/thumbnail.png`), `${this.identifyPrefix}识别:油管,视频下载中请耐心等待 \n视频标题:${title}\n视频时长:${(Duration / 60).toFixed(2).replace(/\.00$/, '')} 分钟`]); + await ytDlpHelper(path, url, isOversea, this.myProxy, this.videoDownloadConcurrency, true, graphics, timeRange); + this.sendVideoToUpload(e, `${path}/temp.mp4`); } - await ytDlpHelper(path, url, isOversea, this.myProxy, this.videoDownloadConcurrency, true, graphics, timeRange ); - this.sendVideoToUpload(e, `${ path }/temp.mp4`); } catch (error) { logger.error(error); throw error; // Rethrow the error so it can be handled by the caller diff --git a/config/tools.yaml b/config/tools.yaml index 6a2c75d..95487c5 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -11,7 +11,7 @@ streamCompatibility: false # 兼容模式,NCQQ不用开,其他ICQQ、LLO需 biliSessData: '' # 哔哩哔哩的SESSDATA biliIntroLenLimit: 50 # 哔哩哔哩简介长度限制,填 0 或者 -1 可以不做任何限制,显示完整简介 -biliDuration: 480 # 哔哩哔哩限制的最大视频时长(默认8分钟),单位:秒 +biliDuration: 480 # 哔哩哔哩限制的最大视频时长(默认8分钟),单位:秒 biliDisplayCover: true # 是否显示哔哩哔哩的封面 biliDisplayInfo: true # 是否显示哔哩哔哩的视频信息 biliDisplayIntro: true # 是否显示哔哩哔哩的简介 @@ -27,8 +27,9 @@ neteaseCookie: '' # 网易云ck neteaseCloudAPIServer: '' # 网易云自建服务器地址 neteaseCloudAudioQuality: exhigh # 网易云解析最高音质 默认exhigh(极高) 分类:standard => 标准,higher => 较高, exhigh=>极高, lossless=>无损, hires=>Hi-Res, jyeffect => 高清环绕声, sky => 沉浸环绕声, dolby => 杜比全景声, jymaster => 超清母带 -YouTubeGraphicsOptions: 720 # YouTobe的下载画质,0为原画,1080,720,480,自定义画面高度(默认为720) -youtubeDuration: 300 # YouTobe限制的最大视频时长(默认5分钟),单位:秒 +youtubeGraphicsOptions: 720 # YouTobe的下载画质,0为原画,1080,720,480,自定义画面高度(默认为720) +youtubeClipTime: # YouTobe限制的最大视频时长(默认不开启),单位:秒 最好不要超过5分钟,否则截取效率非常低 +youtubeDuration: 480 # YouTobe限制的最大视频时长(默认8分钟),单位:秒 最好不要超过30分钟,否则截取效率非常低 douyinCookie: '' # douyin's cookie, 格式:odin_tt=xxx;passport_fe_beating_status=xxx;sid_guard=xxx;uid_tt=xxx;uid_tt_ss=xxx;sid_tt=xxx;sessionid=xxx;sessionid_ss=xxx;sid_ucp_v1=xxx;ssid_ucp_v1=xxx;passport_assist_user=xxx;ttwid=xxx; douyinCompression: true # true-压缩,false-不压缩;是否使用压缩视频格式的抖音(默认使用),使用后加速视频发送 diff --git a/guoba.support.js b/guoba.support.js index 600d478..c01219b 100644 --- a/guoba.support.js +++ b/guoba.support.js @@ -222,17 +222,28 @@ export function supportGuoba() { }, { field: "tools.youtubeDuration", - label: "YouTuBe最大时长", + label: "YouTuBe最大解析时长", bottomHelpMessage: - "超过时长会截取指定时间(单位:秒),保护魔法的流量,计算公式:5分钟 x 60秒 = 300秒", + "超过时长不解析(单位:秒),保护魔法的流量,计算公式:8分钟 x 60秒 = 480秒,默认8分钟,最好不超过30分钟", component: "InputNumber", required: false, componentProps: { - placeholder: "请输入YouTuBe视频最大时长限制(默认5分钟)", + placeholder: "请输入YouTuBe视频最大时长限制", }, }, { - field: "tools.YouTubeGraphicsOptions", + field: "tools.youtubeClipTime", + label: "YouTuBe截取时长", + bottomHelpMessage: + "超过时长会截取指定时间(单位:秒),保护魔法的流量,计算公式:3分钟 x 60秒 = 180秒,默认不开启,最好不超过5分钟", + component: "InputNumber", + required: false, + componentProps: { + placeholder: "请输入YouTuBe视频最大时长限制", + }, + }, + { + field: "tools.youtubeGraphicsOptions", label: "YouTube最高分辨率", bottomHelpMessage: "油管下载的最高分辨率(默认720p,请根据自己魔法流量和服务器承载能力进行调整)", From 16387b803f79d4dc250ec7f083f4636129ccba6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E5=88=80=E9=B1=BC?= <9903082+qdyovo@user.noreply.gitee.com> Date: Fri, 18 Oct 2024 10:50:12 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=8E=88pref=EF=BC=9A=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 2 +- guoba.support.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 8454aaf..60fd81b 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -1956,7 +1956,7 @@ export class tools extends plugin { } const path = this.getCurDownloadPath(e); await checkAndRemoveFile(path + "/temp.mp4") - await checkAndRemoveFile(path + "/Thumbnail.png") + await checkAndRemoveFile(path + "/thumbnail.png") await ytDlpGetThumbnail(path, url, isOversea, this.myProxy) const title = await ytDlpGetTilt(url, isOversea, this.myProxy).toString().replace(/\n/g, ''); // logger.info('标题------',title) diff --git a/guoba.support.js b/guoba.support.js index c01219b..2c2651d 100644 --- a/guoba.support.js +++ b/guoba.support.js @@ -235,11 +235,11 @@ export function supportGuoba() { field: "tools.youtubeClipTime", label: "YouTuBe截取时长", bottomHelpMessage: - "超过时长会截取指定时间(单位:秒),保护魔法的流量,计算公式:3分钟 x 60秒 = 180秒,默认不开启,最好不超过5分钟", + "超过时长会截取指定时间(单位:秒),保护魔法的流量,计算公式:3分钟 x 60秒 = 180秒,默认不开启,最好不超过5分钟,0表无限or不开启", component: "InputNumber", required: false, componentProps: { - placeholder: "请输入YouTuBe视频最大时长限制", + placeholder: "请输入截取时长", }, }, { From 56ef54aecffdde8ceee1c04a5f2dad7303b7535f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E5=88=80=E9=B1=BC?= <9903082+qdyovo@user.noreply.gitee.com> Date: Fri, 18 Oct 2024 10:53:26 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=BD=91=E6=98=93=E8=80=81=E7=89=88=E6=9C=AC=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E4=B9=9F=E4=BC=9A=E8=A2=AB=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/tools.js b/apps/tools.js index 60fd81b..1e9e243 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -1615,7 +1615,7 @@ export class tools extends plugin { musicUrlReg2.exec(message)?.[3] || musicUrlReg.exec(message)?.[2] || musicUrlReg3.exec(message)?.[2] || - /id=(\d+)/.exec(message)[1]; + /\bid=(\d+)/.exec(message)[1]; // 如果没有下载地址跳出if if (_.isEmpty(id)) { e.reply(`识别:网易云音乐,解析失败!`); From 29970ec1c57e148c15d9c2b0cb1c183841b2fc87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E5=88=80=E9=B1=BC?= <9903082+qdyovo@user.noreply.gitee.com> Date: Fri, 18 Oct 2024 11:00:51 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=90=9E=20fix=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=BD=91=E6=98=93=E4=BA=91MV=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/tools.js b/apps/tools.js index 1e9e243..4e030fc 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -1615,7 +1615,7 @@ export class tools extends plugin { musicUrlReg2.exec(message)?.[3] || musicUrlReg.exec(message)?.[2] || musicUrlReg3.exec(message)?.[2] || - /\bid=(\d+)/.exec(message)[1]; + /(?