From 823e9ddbb57ac4146ba4adcfae038805569bd1ec Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Tue, 13 Aug 2024 22:08:26 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=9F=20feat:=20=E5=B0=8F=E9=A3=9E?= =?UTF-8?q?=E6=9C=BA=E5=A2=9E=E5=8A=A0=E5=A4=9A=E7=BA=BF=E7=A8=8B=E8=83=BD?= =?UTF-8?q?=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 11 +++++++---- utils/tdl-util.js | 7 +++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 48184d8..24033b1 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -1780,10 +1780,14 @@ export class tools extends plugin { return; } const url = urlRex.exec(e.msg)[0]; - const tgSavePath = `${this.getCurDownloadPath(e)}/tg`; - await mkdirIfNotExists(tgSavePath); - await startTDL(url, tgSavePath, isOversea, this.myProxy); e.reply(`识别:小飞机(学习版)`); + const tgSavePath = `${this.getCurDownloadPath(e)}/tg`; + // 如果没有文件夹则创建 + await mkdirIfNotExists(tgSavePath); + // 删除之前的文件 + await deleteFolderRecursive(tgSavePath); + await startTDL(url, tgSavePath, isOversea, this.myProxy, this.videoDownloadConcurrency); + // 过滤当前文件 const mediaFiles = await getMediaFiles(tgSavePath); if (mediaFiles.images.length > 0) { const imagesData = mediaFiles.images.map(item => { @@ -1800,7 +1804,6 @@ export class tools extends plugin { await this.sendVideoToUpload(e, `${tgSavePath}/${item}`); } } - await deleteFolderRecursive(tgSavePath); return true; } diff --git a/utils/tdl-util.js b/utils/tdl-util.js index b1e167c..15d2b36 100644 --- a/utils/tdl-util.js +++ b/utils/tdl-util.js @@ -7,13 +7,16 @@ import path from 'path' * @param curPath * @param isOversea * @param proxyAddr + * @param videoDownloadConcurrency * @returns {Promise} */ -export async function startTDL(url, curPath, isOversea, proxyAddr) { +export async function startTDL(url, curPath, isOversea, proxyAddr, videoDownloadConcurrency = 1) { return new Promise((resolve, reject) => { curPath = path.resolve(curPath); const proxyStr = isOversea ? `` : `--proxy ${ proxyAddr }`; - const command = `tdl dl -u ${url} -d ${curPath} ${proxyStr}` + const concurrencyStr = videoDownloadConcurrency > 1 ? `-t ${videoDownloadConcurrency} -s 524288 -l ${videoDownloadConcurrency}` : ''; + const command = `tdl dl -u ${url} -d ${curPath} ${concurrencyStr} ${proxyStr}` + logger.mark(`[R插件][TDL] ${command}`); exec(command, (error, stdout, stderr) => { if (error) { reject(`[R插件][TDL]执行出错: ${error.message}`);