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

This commit is contained in:
lyswhut
2019-09-10 13:00:55 +08:00
parent a432080141
commit 16149fdd38
3 changed files with 5 additions and 2 deletions
+1 -1
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)
+3 -1
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,