From 05b49f4b74855f4822ad98d41f231d37548bf5da Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Wed, 7 Aug 2024 16:27:54 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20`Aria2`=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=A4=9A=E7=BA=BF=E7=A8=8B=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 6 ++++-- utils/bilibili.js | 18 +++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index aee0b16..a884521 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -1807,7 +1807,8 @@ export class tools extends plugin { }), 1000, ), - this.biliUseAria2 + this.biliUseAria2, + this.videoDownloadConcurrency ), downloadBFile( audioUrl, @@ -1819,7 +1820,8 @@ export class tools extends plugin { }), 1000, ), - this.biliUseAria2 + this.biliUseAria2, + this.videoDownloadConcurrency ), ]).then(data => { return mergeFileToMp4(data[0].fullFileName, data[1].fullFileName, `${ title }.mp4`); diff --git a/utils/bilibili.js b/utils/bilibili.js index 8e57caf..03a392d 100644 --- a/utils/bilibili.js +++ b/utils/bilibili.js @@ -22,15 +22,16 @@ const biliHeaders = { /** * 下载单个bili文件 - * @param url - * @param fullFileName - * @param progressCallback - * @param isAria2 + * @param url 下载链接 + * @param fullFileName 文件名 + * @param progressCallback 下载进度 + * @param isAria2 是否使用aria2 + * @param videoDownloadConcurrency 视频下载并发 * @returns {Promise} */ -export async function downloadBFile(url, fullFileName, progressCallback, isAria2 = false) { +export async function downloadBFile(url, fullFileName, progressCallback, isAria2 = false, videoDownloadConcurrency = 1) { if (isAria2) { - return aria2DownloadBFile(url, fullFileName, progressCallback); + return aria2DownloadBFile(url, fullFileName, progressCallback, videoDownloadConcurrency); } else { return normalDownloadBFile(url, fullFileName, progressCallback); } @@ -78,9 +79,10 @@ async function normalDownloadBFile(url, fullFileName, progressCallback) { * @param url * @param fullFileName * @param progressCallback + * @param videoDownloadConcurrency * @returns {Promise} */ -async function aria2DownloadBFile(url, fullFileName, progressCallback) { +async function aria2DownloadBFile(url, fullFileName, progressCallback, videoDownloadConcurrency) { return new Promise((resolve, reject) => { logger.info(`[R插件][Aria2下载] 正在使用Aria2进行下载!`); // 构建aria2c命令 @@ -91,6 +93,8 @@ async function aria2DownloadBFile(url, fullFileName, progressCallback) { '--console-log-level=warn', // 减少日志 verbosity '--download-result=hide', // 隐藏下载结果概要 '--header', 'referer: https://www.bilibili.com', // 添加自定义标头 + `--max-connection-per-server=${videoDownloadConcurrency}`, // 每个服务器的最大连接数 + `--split=${videoDownloadConcurrency}`, // 分成 6 个部分进行下载 url ];