From 042935e2712b011500aacd55ab38707b7a4f6480 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Sun, 25 Aug 2024 21:20:27 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=B7=BB=E5=8A=A0`?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=A3=9E=E6=9C=BA`=E5=8A=AB=E6=8C=81?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/tdl-util.js | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/utils/tdl-util.js b/utils/tdl-util.js index 332d084..94ae720 100644 --- a/utils/tdl-util.js +++ b/utils/tdl-util.js @@ -14,16 +14,16 @@ export async function startTDL(url, curPath, isOversea, proxyAddr, videoDownload return new Promise((resolve, reject) => { curPath = path.resolve(curPath); const proxyStr = isOversea ? `` : `--proxy ${ proxyAddr }`; - 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}`); + 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}`); + reject(`[R插件][TDL]执行出错: ${ error.message }`); return; } if (stderr) { - reject(`[R插件][TDL]错误信息: ${stderr}`); + reject(`[R插件][TDL]错误信息: ${ stderr }`); return; } resolve(stdout); @@ -41,14 +41,14 @@ export async function startTDL(url, curPath, isOversea, proxyAddr, videoDownload export async function saveTDL(url, isOversea, proxyAddr) { return new Promise((resolve, reject) => { const proxyStr = isOversea ? `` : `--proxy ${ proxyAddr }`; - const command = `tdl forward --from ${url} ${proxyStr}` + const command = `tdl forward --from ${ url } ${ proxyStr }` exec(command, (error, stdout, stderr) => { if (error) { - reject(`[R插件][TDL保存]执行出错: ${error.message}`); + reject(`[R插件][TDL保存]执行出错: ${ error.message }`); return; } if (stderr) { - reject(`[R插件][TDL保存]错误信息: ${stderr}`); + reject(`[R插件][TDL保存]错误信息: ${ stderr }`); return; } resolve(stdout); @@ -64,17 +64,19 @@ export async function saveTDL(url, isOversea, proxyAddr) { * @returns {Promise} */ export async function uploadTDL(filePath, isOversea, proxyAddr) { - const proxyStr = isOversea ? `` : `--proxy ${ proxyAddr }`; - const command = `tdl up -p ${ filePath } ${ proxyStr }`; - exec(command, (error, stdout, stderr) => { - if (error) { - reject(`[R插件][TDL上传]执行出错: ${error.message}`); - return; - } - if (stderr) { - reject(`[R插件][TDL上传]错误信息: ${stderr}`); - return; - } - resolve(stdout); + return new Promise((resolve, reject) => { + const proxyStr = isOversea ? `` : `--proxy ${ proxyAddr }`; + const command = `tdl up -p ${ filePath } ${ proxyStr }`; + exec(command, (error, stdout, stderr) => { + if (error) { + reject(`[R插件][TDL上传]执行出错: ${ error.message }`); + return; + } + if (stderr) { + reject(`[R插件][TDL上传]错误信息: ${ stderr }`); + return; + } + resolve(stdout); + }) }) }