From bcde463330be241bbbbad3d9c53b83439f6bb409 Mon Sep 17 00:00:00 2001 From: "DESKTOP-I4SRUE6\\NikoYoke" Date: Thu, 17 Oct 2024 19:33:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=8E=88pref=EF=BC=9A=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=8F=AF=E8=83=BD=E5=A4=9A=E6=AC=A1=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E8=A7=86=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/yt-dlp-util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/yt-dlp-util.js b/utils/yt-dlp-util.js index d9eb488..e00a1ea 100644 --- a/utils/yt-dlp-util.js +++ b/utils/yt-dlp-util.js @@ -19,7 +19,7 @@ function constructProxyParam(isOversea, proxy) { * @returns string */ export function ytDlpGetDuration(url, isOversea, proxy) { - return execSync(`yt-dlp --get-duration ${constructProxyParam(isOversea, proxy)} ${url}`); + return execSync(`yt-dlp --get-duration --skip-download ${constructProxyParam(isOversea, proxy)} ${url}`); } /** @@ -30,7 +30,7 @@ export function ytDlpGetDuration(url, isOversea, proxy) { * @returns string */ export function ytDlpGetTilt(url, isOversea, proxy) { - return execSync(`yt-dlp --get-title ${constructProxyParam(isOversea, proxy)} ${url} --encoding utf8`); + return execSync(`yt-dlp --get-title --skip-download ${constructProxyParam(isOversea, proxy)} ${url} --encoding utf8`); } /** From 240d042455ad9ea7a3d040ea9834528fb79cbfb4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-I4SRUE6\\NikoYoke" Date: Thu, 17 Oct 2024 19:35:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E6=B2=B9=E7=AE=A1?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E6=88=90=E5=8A=9F=E5=90=8E=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=97=B6=E9=95=BF=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 1ea8ea3..fe9830d 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -1956,21 +1956,22 @@ export class tools extends plugin { await checkAndRemoveFile(path + "/temp.mp4") await checkAndRemoveFile(path + "/Thumbnail.png") await ytDlpGetThumbnail(path, url, isOversea, this.myProxy) - const Duration = await ytDlpGetDuration(url, isOversea, this.myProxy).toString().replace(/\n/g, '') - // logger.info('时长------',Duration) const title = await ytDlpGetTilt(url, isOversea, this.myProxy).toString().replace(/\n/g, ''); // logger.info('标题------',title) function convertToSeconds(timeStr) { const [minutes, seconds] = timeStr.split(':').map(Number); // 拆分并转换为数字 + if (!seconds) return timeStr; return minutes * 60 + seconds; // 分钟转化为秒并加上秒数 } - if(await convertToSeconds(Duration) > this.youtubeDuration){ + const Duration = convertToSeconds(await ytDlpGetDuration(url, isOversea, this.myProxy).toString().replace(/\n/g, '')) + // logger.info('时长------',Duration) + if(Duration > this.youtubeDuration){ e.reply([ - segment.image(`${path}/thumbnail.png`), - `${this.identifyPrefix}识别:油管,视频下载中请耐心等待 \n视频标题:${title}${DIVIDING_LINE.replace('{}', '限制说明')}\n视频时长:${Duration}分钟\n大于管理员限定时长:${(this.youtubeDuration / 60).toFixed(2).replace(/\.00$/, '')} 分钟\n将截取限定时间部分` + 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将截取限定时间部分` ]); } else { - e.reply([segment.image(`${ path }/thumbnail.png`),`${ this.identifyPrefix }识别:油管,视频下载中请耐心等待 \n视频标题:${ title }\n视频时长:${Duration} 分钟`]); + 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, true, graphics, timeRange); this.sendVideoToUpload(e, `${ path }/temp.mp4`);