修复歌曲时文件名过长导致歌曲无法下载的问题(#1877)
parent
ee6a6f4b94
commit
b680a89033
|
@ -17,6 +17,7 @@
|
||||||
- 修复Mac下即使开启了托盘, `cmd+w` 仍会中断播放的问题(#1844)
|
- 修复Mac下即使开启了托盘, `cmd+w` 仍会中断播放的问题(#1844)
|
||||||
- 修复播放详情页的歌词无法使用触碰拖动的问题(#1865)
|
- 修复播放详情页的歌词无法使用触碰拖动的问题(#1865)
|
||||||
- 修复与优化繁体中文、英语翻译显示(#1845)
|
- 修复与优化繁体中文、英语翻译显示(#1845)
|
||||||
|
- 修复歌曲时文件名过长导致歌曲无法下载的问题(#1877)
|
||||||
|
|
||||||
### 变更
|
### 变更
|
||||||
|
|
||||||
|
|
|
@ -321,7 +321,7 @@ class Task extends EventEmitter {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
this.__handleError(err)
|
this.__handleError(err)
|
||||||
void this.stop()
|
return
|
||||||
}
|
}
|
||||||
if (this.closeWaiting && !this.dataWriteQueueLength) this.ws?.close()
|
if (this.closeWaiting && !this.dataWriteQueueLength) this.ws?.close()
|
||||||
})
|
})
|
||||||
|
|
|
@ -192,7 +192,8 @@ const downloadLyric = (downloadInfo: LX.Download.ListItem) => {
|
||||||
tlrc: appSetting['download.isDownloadTLrc'] && lrcs.tlyric ? lrcs.tlyric : null,
|
tlrc: appSetting['download.isDownloadTLrc'] && lrcs.tlyric ? lrcs.tlyric : null,
|
||||||
rlrc: appSetting['download.isDownloadRLrc'] && lrcs.rlyric ? lrcs.rlyric : null,
|
rlrc: appSetting['download.isDownloadRLrc'] && lrcs.rlyric ? lrcs.rlyric : null,
|
||||||
}
|
}
|
||||||
void window.lx.worker.download.saveLrc(lrcData, downloadInfo.metadata.filePath.replace(/(mp3|flac|ape|wav)$/, 'lrc'),
|
void window.lx.worker.download.saveLrc(lrcData,
|
||||||
|
downloadInfo.metadata.filePath.substring(0, downloadInfo.metadata.filePath.lastIndexOf('.')) + '.lrc',
|
||||||
appSetting['download.lrcFormat'])
|
appSetting['download.lrcFormat'])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -114,7 +114,7 @@ const createTask = async(downloadInfo: LX.Download.ListItem, savePath: string, s
|
||||||
console.log('on complate')
|
console.log('on complate')
|
||||||
},
|
},
|
||||||
onError(err: any) {
|
onError(err: any) {
|
||||||
console.log(err)
|
console.error(err)
|
||||||
if (err.code == 'EPERM') {
|
if (err.code == 'EPERM') {
|
||||||
sendAction(downloadInfo.id, {
|
sendAction(downloadInfo.id, {
|
||||||
action: 'error',
|
action: 'error',
|
||||||
|
@ -157,8 +157,9 @@ const createTask = async(downloadInfo: LX.Download.ListItem, savePath: string, s
|
||||||
sendAction(downloadInfo.id, { action: 'refreshUrl' })
|
sendAction(downloadInfo.id, { action: 'refreshUrl' })
|
||||||
} else {
|
} else {
|
||||||
console.log('Download failed, Attempting Retry')
|
console.log('Download failed, Attempting Retry')
|
||||||
void dls.get(downloadInfo.id)?.start()
|
setTimeout(() => {
|
||||||
console.log('正在重试')
|
void dls.get(downloadInfo.id)?.start()
|
||||||
|
}, 1000)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onFail(response) {
|
onFail(response) {
|
||||||
|
|
|
@ -65,7 +65,21 @@ export const getMusicType = (musicInfo: LX.Music.MusicInfoOnline, type: LX.Quali
|
||||||
// const checkExistList = (list: LX.Download.ListItem[], musicInfo: LX.Music.MusicInfo, type: LX.Quality, ext: string): boolean => {
|
// const checkExistList = (list: LX.Download.ListItem[], musicInfo: LX.Music.MusicInfo, type: LX.Quality, ext: string): boolean => {
|
||||||
// return list.some(s => s.id === musicInfo.id && (s.metadata.type === type || s.metadata.ext === ext))
|
// return list.some(s => s.id === musicInfo.id && (s.metadata.type === type || s.metadata.ext === ext))
|
||||||
// }
|
// }
|
||||||
|
const MAX_NAME_LENGTH = 80
|
||||||
|
const MAX_FILE_NAME_LENGTH = 150
|
||||||
|
const clipNameLength = (name: string) => {
|
||||||
|
if (name.length <= MAX_NAME_LENGTH || !name.includes('、')) return name
|
||||||
|
const names = name.split('、')
|
||||||
|
let newName = names.shift()!
|
||||||
|
for (const name of names) {
|
||||||
|
if (newName.length + name.length > MAX_NAME_LENGTH) break
|
||||||
|
newName = newName + '、' + name
|
||||||
|
}
|
||||||
|
return newName
|
||||||
|
}
|
||||||
|
const clipFileNameLength = (name: string) => {
|
||||||
|
return name.length > MAX_FILE_NAME_LENGTH ? name.substring(0, MAX_FILE_NAME_LENGTH) : name
|
||||||
|
}
|
||||||
export const createDownloadInfo = (musicInfo: LX.Music.MusicInfoOnline, type: LX.Quality, fileName: string, savePath: string, qualityList: LX.QualityList) => {
|
export const createDownloadInfo = (musicInfo: LX.Music.MusicInfoOnline, type: LX.Quality, fileName: string, savePath: string, qualityList: LX.QualityList) => {
|
||||||
type = getMusicType(musicInfo, type, qualityList)
|
type = getMusicType(musicInfo, type, qualityList)
|
||||||
let ext = getExt(type)
|
let ext = getExt(type)
|
||||||
|
@ -87,9 +101,9 @@ export const createDownloadInfo = (musicInfo: LX.Music.MusicInfoOnline, type: LX
|
||||||
quality: type,
|
quality: type,
|
||||||
ext,
|
ext,
|
||||||
filePath: '',
|
filePath: '',
|
||||||
fileName: filterFileName(`${fileName
|
fileName: filterFileName(`${clipFileNameLength(fileName
|
||||||
.replace('歌名', musicInfo.name)
|
.replace('歌名', musicInfo.name)
|
||||||
.replace('歌手', musicInfo.singer)}.${ext}`),
|
.replace('歌手', clipNameLength(musicInfo.singer)))}.${ext}`),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
downloadInfo.metadata.filePath = joinPath(savePath, downloadInfo.metadata.fileName)
|
downloadInfo.metadata.filePath = joinPath(savePath, downloadInfo.metadata.fileName)
|
||||||
|
|
Loading…
Reference in New Issue