From 7609e303b206ec9031226f8a37c0ab9b04741253 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Thu, 15 Aug 2024 20:13:28 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=9B=20chore:=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=83=A8=E5=88=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 6 +++--- utils/common.js | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index bbc276d..01941c5 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -937,7 +937,7 @@ export class tools extends plugin { proxyAddr: this.proxyAddr, proxyPort: this.proxyPort }, - numThread: 1, + downloadMethod: this.biliDownloadMethod, }) e.reply(segment.image(xImgPath)); } @@ -1047,7 +1047,7 @@ export class tools extends plugin { img: item.urlDefault, dir: downloadPath, fileName: `${index}.png`, - numThread: 1, + downloadMethod: this.biliDownloadMethod, })); } // 等待所有图片下载完成 @@ -1265,7 +1265,7 @@ export class tools extends plugin { headersExt: { "Referer": "http://blog.sina.com.cn/", }, - numThread: 1, + downloadMethod: this.biliDownloadMethod, }).then(async (filePath) => { // 格式化为消息对象 return { diff --git a/utils/common.js b/utils/common.js index d9e871d..6484dc9 100644 --- a/utils/common.js +++ b/utils/common.js @@ -7,7 +7,7 @@ import fs from "node:fs"; import os from "os"; import common from "../../../lib/common/common.js"; import path from 'path'; -import { COMMON_USER_AGENT, TEN_THOUSAND } from "../constants/constant.js"; +import { BILI_DOWNLOAD_METHOD, COMMON_USER_AGENT, TEN_THOUSAND } from "../constants/constant.js"; import { mkdirIfNotExists } from "./file.js"; /** @@ -204,7 +204,7 @@ export async function downloadImg({ isProxy = false, headersExt = {}, proxyInfo = {}, - numThread = 1, + downloadMethod = 0, }) { const downloadImgParams = { img, @@ -213,12 +213,11 @@ export async function downloadImg({ isProxy, headersExt, proxyInfo, - numThread, } - logger.info(logger.yellow(`[R插件][图片下载] 当前使用线程数:${ numThread }`)); - if (numThread === 1) { + logger.info(logger.yellow(`[R插件][图片下载] 当前使用的方法:${ BILI_DOWNLOAD_METHOD[downloadMethod].label }`)); + if (downloadMethod === 0) { return normalDownloadImg(downloadImgParams); - } else if (numThread > 1) { + } else if (downloadMethod === 1) { return downloadImgWithAria2(downloadImgParams); } }