From e9dd342e88ff8940eb69df614aed8a9eceae2329 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Wed, 6 Nov 2024 17:08:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B2=B9=E7=AE=A1=E9=A5=BC=E5=B9=B2=E9=80=89=E9=A1=B9=EF=BC=8C?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E9=83=A8=E5=88=86=E4=B8=AA=E8=87=AA=E6=97=A0?= =?UTF-8?q?=E6=B3=95=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 +- utils/yt-dlp-util.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index cea5897..d84f849 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -2000,7 +2000,7 @@ export class tools extends plugin { } // 下面为视频逻辑 - const Duration = convertToSeconds(await ytDlpGetDuration(url, isOversea, this.myProxy).toString().replace(/\n/g, '')); + const Duration = convertToSeconds(ytDlpGetDuration(url, isOversea, this.myProxy, this.youtubeCookiePath).toString().replace(/\n/g, '')); // logger.info('时长------',Duration) if (Duration > this.youtubeDuration) { e.reply([ diff --git a/utils/yt-dlp-util.js b/utils/yt-dlp-util.js index 3b7012c..692bb80 100644 --- a/utils/yt-dlp-util.js +++ b/utils/yt-dlp-util.js @@ -36,10 +36,13 @@ function constructEncodingParam(url) { * @param url * @param isOversea * @param proxy + * @param cookiePath * @returns string */ -export function ytDlpGetDuration(url, isOversea, proxy) { - return execSync(`yt-dlp --get-duration --skip-download ${constructProxyParam(isOversea, proxy)} ${url}`); +export function ytDlpGetDuration(url, isOversea, proxy, cookiePath = "") { + // 构造 cookie 参数 + const cookieParam = constructCookiePath(url, cookiePath); + return execSync(`yt-dlp --get-duration --skip-download ${cookieParam} ${constructProxyParam(isOversea, proxy)} ${url}`); } /**