From e2503023c66aeeaa63f8413b8b4cffdeecb7fb49 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Wed, 29 May 2024 21:27:51 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=A2=9E=E5=8A=A0=E5=AF=B9?= =?UTF-8?q?=E5=93=94=E5=93=A9=E5=93=94=E5=93=A9=E7=AE=80=E4=BB=8B=E7=9A=84?= =?UTF-8?q?ytb=E6=A3=80=E6=B5=8B=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 6 ++++-- utils/bilibili.js | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index c258e18..c9fbe02 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -10,7 +10,7 @@ import HttpProxyAgent from "https-proxy-agent"; import { exec, execSync } from "child_process"; import { checkAndRemoveFile, deleteFolderRecursive, mkdirIfNotExists } from "../utils/file.js"; import { - downloadBFile, + downloadBFile, filterBiliDescLink, getBiliAudio, getBiliVideoWithSession, getDownloadUrl, @@ -460,8 +460,10 @@ export class tools extends plugin { "弹幕数量": danmaku, "评论": reply }; + // 过滤简介中的一些链接 + const filteredDesc = await filterBiliDescLink(desc); // 格式化数据 - const combineContent = `\n${ formatBiliInfo(dataProcessMap) }\n简介:${ truncateString(desc, this.toolsConfig.biliIntroLenLimit || BILI_DEFAULT_INTRO_LEN_LIMIT) }`; + const combineContent = `\n${ formatBiliInfo(dataProcessMap) }\n简介:${ truncateString(filteredDesc, this.toolsConfig.biliIntroLenLimit || BILI_DEFAULT_INTRO_LEN_LIMIT) }`; let biliInfo = [`识别:哔哩哔哩:${ title }`, combineContent] // 总结 const summary = await this.getBiliSummary(bvid, cid, owner.mid); diff --git a/utils/bilibili.js b/utils/bilibili.js index 85564fc..0dd95d5 100644 --- a/utils/bilibili.js +++ b/utils/bilibili.js @@ -332,4 +332,19 @@ export async function getScanCodeData(qrcodeSavePath = 'qrcode.png', detectTime refresh_token: '' }; } +} + +/** + * 过滤简介中的一些链接 + * @param link + * @returns {Promise} + */ +export async function filterBiliDescLink(link) { + // YouTube链接 + const regex = /(?:https?:\/\/)?(?:www\.|music\.)?youtube\.com\/[A-Za-z\d._?%&+\-=\/#]*/g; + if (regex.test(link)) { + // 使用replace方法过滤掉匹配的链接 + return link.replace(regex, '').replace(/\n/g, '').trim(); + } + return link; } \ No newline at end of file