diff --git a/publish/changeLog.md b/publish/changeLog.md index f73ff859..2d9b5fd2 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,3 +1,4 @@ ### 修复 - 修复 MAC 系统下软件关闭时再次从 dock 打开时报错的Bug +- 修复下载的歌曲文件名中包含命名规则不允许的符号时下载失败的问题(若歌曲名包含这些符号会自动将其移除) diff --git a/src/main/utils/mp3Meta.js b/src/main/utils/mp3Meta.js index 5b5950ea..fd0526e1 100644 --- a/src/main/utils/mp3Meta.js +++ b/src/main/utils/mp3Meta.js @@ -6,7 +6,7 @@ const extReg = /^(\.(?:jpe?g|png)).*$/ module.exports = (filePath, meta) => { if (!meta.APIC) return NodeID3.write(meta, filePath) - let picPath = path.join(path.dirname(filePath), `${meta.title}-${meta.artist}${path.extname(meta.APIC).replace(extReg, '$1')}`) + let picPath = filePath.replace(/\.mp3$/, '') + path.extname(meta.APIC).replace(extReg, '$1') request(meta.APIC).pipe(fs.createWriteStream(picPath)).on('finish', () => { meta.APIC = picPath NodeID3.write(meta, filePath) diff --git a/src/renderer/store/modules/download.js b/src/renderer/store/modules/download.js index 430143ba..b369d19b 100644 --- a/src/renderer/store/modules/download.js +++ b/src/renderer/store/modules/download.js @@ -22,6 +22,8 @@ const state = { const dls = {} const tryNum = {} +const filterFileName = /[\\/:*?#"<>|]/g + // getters const getters = { list: state => state.list || [], @@ -125,7 +127,7 @@ const actions = { url: null, fileName: `${rootState.setting.download.fileName .replace('歌名', musicInfo.name) - .replace('歌手', musicInfo.singer)}.${ext}`, + .replace('歌手', musicInfo.singer)}.${ext}`.replace(filterFileName, ''), progress: { downloaded: 0, total: 0,