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}`);