From 56333de309d1d28de2ae74cbe843dffc81a62e81 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Mon, 16 Sep 2024 21:06:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20pref:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=89=B9=E6=AE=8A=E7=AC=A6=E5=8F=B7=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 2 +- utils/common.js | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 05e529e..0a17395 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -1248,7 +1248,7 @@ export class tools extends plugin { // 获取歌曲信息 let title = await axios.get(AUTO_NETEASE_SONG_DETAIL.replace("{}", id)).then(res => { const song = res.data.songs[0]; - return `${ song?.name }-${ song?.ar?.[0].name }`.replace(/[\/\?<>\\:\*\|".… ]/g, ""); + return cleanFilename(`${ song?.name }-${ song?.ar?.[0].name }`); }); // 一般这个情况是VIP歌曲 (如果没有url或者是国内, 国内全走临时接口,后续如果不要删除逻辑'!isOversea ||') if (!isOversea || url == null) { diff --git a/utils/common.js b/utils/common.js index d9a037f..85e936e 100644 --- a/utils/common.js +++ b/utils/common.js @@ -427,14 +427,11 @@ export function saveJsonToFile(jsonData, filename = "data.json") { * @returns {string} */ export function cleanFilename(filename) { - // 去除省略号(…) - filename = filename.replace(/…/g, ''); - // 删除括号及其内容 - filename = filename.replace(/\(|\)/g, ''); - // 删除反斜杠 - filename = filename.replace(/\//g, ''); - - filename = filename.trim(); + // 1. 去除特殊字符 + // 2. 去除特定词汇 + filename = filename.replace(/[\/\?<>\\:\*\|".…《》()]/g, '') + .replace(/电影|主题曲/g, '') + .trim(); return filename; }