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