修复:文件名包含特殊符号时导致下载失败的Bug

pull/96/head
lyswhut 2019-09-10 13:00:55 +08:00
parent a432080141
commit 16149fdd38
3 changed files with 5 additions and 2 deletions

View File

@ -1,3 +1,4 @@
### 修复
- 修复 MAC 系统下软件关闭时再次从 dock 打开时报错的Bug
- 修复下载的歌曲文件名中包含命名规则不允许的符号时下载失败的问题(若歌曲名包含这些符号会自动将其移除)

View File

@ -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)

View File

@ -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,