mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
🌟 feat: 小飞机增加多线程能力
This commit is contained in:
parent
1f86a31ec9
commit
823e9ddbb5
@ -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;
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,16 @@ import path from 'path'
|
||||
* @param curPath
|
||||
* @param isOversea
|
||||
* @param proxyAddr
|
||||
* @param videoDownloadConcurrency
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
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}`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user