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; }