mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
✨ feat: Aria2
添加多线程能力
This commit is contained in:
parent
090bd09e1a
commit
05b49f4b74
@ -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`);
|
||||
|
@ -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<any>}
|
||||
*/
|
||||
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<void>}
|
||||
*/
|
||||
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
|
||||
];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user