mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🌟 feat: 小飞机增加多线程能力
This commit is contained in:
parent
1f86a31ec9
commit
823e9ddbb5
@ -1780,10 +1780,14 @@ export class tools extends plugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const url = urlRex.exec(e.msg)[0];
|
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(`识别:小飞机(学习版)`);
|
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);
|
const mediaFiles = await getMediaFiles(tgSavePath);
|
||||||
if (mediaFiles.images.length > 0) {
|
if (mediaFiles.images.length > 0) {
|
||||||
const imagesData = mediaFiles.images.map(item => {
|
const imagesData = mediaFiles.images.map(item => {
|
||||||
@ -1800,7 +1804,6 @@ export class tools extends plugin {
|
|||||||
await this.sendVideoToUpload(e, `${tgSavePath}/${item}`);
|
await this.sendVideoToUpload(e, `${tgSavePath}/${item}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await deleteFolderRecursive(tgSavePath);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,13 +7,16 @@ import path from 'path'
|
|||||||
* @param curPath
|
* @param curPath
|
||||||
* @param isOversea
|
* @param isOversea
|
||||||
* @param proxyAddr
|
* @param proxyAddr
|
||||||
|
* @param videoDownloadConcurrency
|
||||||
* @returns {Promise<string>}
|
* @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) => {
|
return new Promise((resolve, reject) => {
|
||||||
curPath = path.resolve(curPath);
|
curPath = path.resolve(curPath);
|
||||||
const proxyStr = isOversea ? `` : `--proxy ${ proxyAddr }`;
|
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) => {
|
exec(command, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(`[R插件][TDL]执行出错: ${error.message}`);
|
reject(`[R插件][TDL]执行出错: ${error.message}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user