From f8aec9a2ab4efa994cc4ed9efa6a15b50c37d248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E5=88=80=E9=B1=BC?= <102730551+nikoyoke1@users.noreply.github.com> Date: Fri, 27 Sep 2024 11:21:18 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BB=85=E4=B8=BAwindows=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E8=BD=AC=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/tools.js b/apps/tools.js index 7eec3a9..9208ee3 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -1432,7 +1432,12 @@ export class tools extends plugin { try { const urlRex = /(?:https?:\/\/)?(www\.|music\.)?youtube\.com\/[A-Za-z\d._?%&+\-=\/#]*/g; const url2Rex = /(?:https?:\/\/)?youtu\.be\/[A-Za-z\d._?%&+\-=\/#]*/g; - let url = urlRex.exec(e.msg)?.[0]?.replace(/&/g, '^&') || url2Rex.exec(e.msg)?.[0]?.replace(/&/g, '^&'); + // 检测操作系统平台 + const isWindows = process.platform === 'win32'; + + // 匹配并转义 URL 中的 & 符号(仅对 Windows 进行转义) + let url = urlRex.exec(e.msg)?.[0]?.replace(/&/g, isWindows ? '^&' : '&') || + url2Rex.exec(e.msg)?.[0]?.replace(/&/g, isWindows ? '^&' : '&'); // 适配 YouTube Music if (url.includes("music")) { // https://music.youtube.com/watch?v=F4sRtMoIgUs&si=7ZYrHjlI3fHAha0F From f3b3f83da3a4faa18abb94527d0648f7e1146bfb 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, 27 Sep 2024 14:02:00 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BB=85=E5=AF=B9=20?= =?UTF-8?q?windows=20=E8=BF=9B=E8=A1=8C=E8=BD=AC=E4=B9=89?= 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 9208ee3..10e9c15 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -1433,7 +1433,7 @@ export class tools extends plugin { const urlRex = /(?:https?:\/\/)?(www\.|music\.)?youtube\.com\/[A-Za-z\d._?%&+\-=\/#]*/g; const url2Rex = /(?:https?:\/\/)?youtu\.be\/[A-Za-z\d._?%&+\-=\/#]*/g; // 检测操作系统平台 - const isWindows = process.platform === 'win32'; + const isWindows = process.platform === 'win32'; // 匹配并转义 URL 中的 & 符号(仅对 Windows 进行转义) let url = urlRex.exec(e.msg)?.[0]?.replace(/&/g, isWindows ? '^&' : '&') || From 6dcd018511185a2dd1f2b0b12bc140892c0c5c0f 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, 27 Sep 2024 14:03:44 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=94=A7=20refactor:=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20=E6=B2=B9=E7=AE=A1=E8=A7=A3=E6=9E=90=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E4=B8=8B=E8=BD=BD=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/yt-dlp-util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/yt-dlp-util.js b/utils/yt-dlp-util.js index fcd28f3..11ad1ee 100644 --- a/utils/yt-dlp-util.js +++ b/utils/yt-dlp-util.js @@ -34,7 +34,7 @@ export async function ytDlpHelper(path, url, isOversea, proxy, merge = false) { return new Promise((resolve, reject) => { const mergeOption = merge ? '--merge-output-format "mp4"' : ''; - const command = `yt-dlp ${constructProxyParam(isOversea, proxy)} -P ${path} -o "temp.%(ext)s" ${mergeOption} ${url}`; + const command = `yt-dlp -f "bv[height<=720][ext=mp4]+ba[ext=m4a]" ${constructProxyParam(isOversea, proxy)} -P ${path} -o "temp.%(ext)s" ${url}`; exec(command, (error, stdout) => { if (error) { From 26e846bf9df245d12abaa8ddb090b70aee99b1c1 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, 27 Sep 2024 14:05:20 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=94=A7=20refactor:=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20=E6=B2=B9=E7=AE=A1=E8=A7=A3=E6=9E=90=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E4=B8=8B=E8=BD=BD=E7=AD=96=E7=95=A5/=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E6=A0=87=E9=A2=98=E8=BE=93=E5=87=BAutf8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/yt-dlp-util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/yt-dlp-util.js b/utils/yt-dlp-util.js index 11ad1ee..d9ea306 100644 --- a/utils/yt-dlp-util.js +++ b/utils/yt-dlp-util.js @@ -18,7 +18,7 @@ function constructProxyParam(isOversea, proxy) { * @returns string */ export function ytDlpGetTilt(url, isOversea, proxy) { - return execSync(`yt-dlp --get-title ${constructProxyParam(isOversea, proxy)} ${url}`); + return execSync(`yt-dlp --get-title ${constructProxyParam(isOversea, proxy)} ${url} --encoding utf8`); } /**