From e05f7d2901f319d3b4055ee51b3fcc4772609181 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, 15 Nov 2024 12:44:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=8E=88=20pref:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=B2=B9=E7=AE=A1=E9=9F=B3=E4=B9=90=E4=B8=8B=E8=BD=BD=E9=9F=B3?= =?UTF-8?q?=E8=B4=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 8 +++++--- utils/yt-dlp-util.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index cf5defc..8ae255b 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -2052,7 +2052,7 @@ export class tools extends plugin { const path = this.getCurDownloadPath(e); await checkAndRemoveFile(path + "/temp.mp4") - await checkAndRemoveFile(path + "/temp.mp3") + await checkAndRemoveFile(path + "/temp.flac") await checkAndRemoveFile(path + "/thumbnail.png") await ytDlpGetThumbnail(path, url, isOversea, this.myProxy, this.youtubeCookiePath) const title = ytDlpGetTilt(url, isOversea, this.myProxy, this.youtubeCookiePath).toString().replace(/\n/g, ''); @@ -2064,8 +2064,10 @@ export class tools extends plugin { `${this.identifyPrefix}识别:油管音乐\n视频标题:${title}` ]); await ytDlpHelper(path, url, isOversea, this.myProxy, this.videoDownloadConcurrency, true, graphics, timeRange, this.youtubeCookiePath); - e.reply(segment.record(`${path}/temp.mp3`)); - this.uploadGroupFile(e, `${path}/temp.mp3`); + if(this.isSendVocal){ + e.reply(segment.record(`${path}/temp.flac`)); + } + this.uploadGroupFile(e, `${path}/temp.flac`); // 发送完就截断 return; } diff --git a/utils/yt-dlp-util.js b/utils/yt-dlp-util.js index 692bb80..42dffc9 100644 --- a/utils/yt-dlp-util.js +++ b/utils/yt-dlp-util.js @@ -96,7 +96,7 @@ export async function ytDlpHelper(path, url, isOversea, proxy, maxThreads, merge if (url.includes("music")) { // 这里是 YouTube Music的处理逻辑 // e.g yt-dlp -x --audio-format mp3 https://youtu.be/5wEtefq9VzM -o test.mp3 - command = `yt-dlp -x --audio-format mp3 ${cookieParam} ${constructProxyParam(isOversea, proxy)} -P ${path} -o "temp.mp3" ${url}`; + command = `yt-dlp -x --audio-format flac -f ba ${cookieParam} ${constructProxyParam(isOversea, proxy)} -P ${path} -o "temp.flac" ${url}`; } else { // 正常情况下的处理逻辑 const fParam = url.includes("youtu") ? `--download-sections "*${timeRange}" -f "bv${graphics}[ext=mp4]+ba[ext=m4a]" ` : ""; From f48da3b91fd61089f66d8cb4b2ba665b548a31be 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, 15 Nov 2024 13:14:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B2=B9=E7=AE=A1=E8=A7=A3=E6=9E=90=E6=97=B6=E9=97=B4=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/youtube.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/utils/youtube.js b/utils/youtube.js index ec1c7f1..0a5367c 100644 --- a/utils/youtube.js +++ b/utils/youtube.js @@ -30,9 +30,15 @@ export function removeParams(url) { } export function convertToSeconds(timeStr) { - const [hour, minutes, seconds] = timeStr.split(':').map(Number); // 拆分并转换为数字 - if (!seconds) return timeStr; - return hour * 3600 + minutes * 60 + seconds; // 分钟转化为秒并加上秒数 + const parts = timeStr.split(':').map(Number); + if (parts.length === 2) { + const [minutes, seconds] = parts; + return minutes * 60 + seconds; + } else if (parts.length === 3) { + const [hours, minutes, seconds] = parts; + return hours * 3600 + minutes * 60 + seconds; + } + return timeStr; } export async function autoSelectMusicOrVideoSend() {