移除kg源的歌词文件开头的空白字符串

pull/389/head
lyswhut 2020-11-02 15:13:09 +08:00
parent 897107ca23
commit 5c96c83f98
4 changed files with 20 additions and 26 deletions

View File

@ -1,11 +1,3 @@
### 新增
- 播放详情页新增歌曲评论加载显示(某些平台暂不支持显示子评论)
### 优化
- 修改播放详情页的歌曲图片的显示效果
### 修复
- 修复小芸源音乐搜索结果最多只有20条搜索结果的问题
- 移除kg源的歌词文件开头的空白字符串

View File

@ -667,23 +667,15 @@ export default {
}
},
setLrc(targetSong) {
this.musicInfo.lrc = targetSong.lrc
this.musicInfo.tlrc = targetSong.tlrc
let lrcP = this.musicInfo.lrc && this.musicInfo.tlrc != null
? Promise.resolve()
: this.getLrc(targetSong).then(() => {
this.musicInfo.lrc = targetSong.lrc
this.musicInfo.tlrc = targetSong.tlrc
})
lrcP
.catch(() => {
this.status = this.statusText = this.$t('core.player.lyric_error')
}).finally(() => {
this.handleUpdateWinLyricInfo('lyric', { lrc: this.musicInfo.lrc, tlrc: this.musicInfo.tlrc })
this.setLyric()
})
this.getLrc(targetSong).then(() => {
this.musicInfo.lrc = targetSong.lrc
this.musicInfo.tlrc = targetSong.tlrc
}).catch(() => {
this.status = this.statusText = this.$t('core.player.lyric_error')
}).finally(() => {
this.handleUpdateWinLyricInfo('lyric', { lrc: this.musicInfo.lrc, tlrc: this.musicInfo.tlrc })
this.setLyric()
})
},
handleRemoveMusic() {
this.stopPlay()

View File

@ -59,6 +59,15 @@ const actions = {
},
getLrc({ commit, state }, musicInfo) {
if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp()
if (musicInfo.lrc && musicInfo.tlrc != null) {
if (musicInfo.lrc.startsWith('\ufeff[id:$00000000]')) {
let str = musicInfo.lrc.replace('\ufeff[id:$00000000]\n', '')
commit('setLrc', { musicInfo, lyric: str, tlyric: musicInfo.tlrc })
}
return Promise.resolve()
}
lrcRequest = music[musicInfo.source].getLyric(musicInfo)
return lrcRequest.promise.then(({ lyric, tlyric }) => {
lrcRequest = null

View File

@ -3,6 +3,7 @@ import { decodeLyric } from './util'
const parseLyric = str => {
str = str.replace(/(?:<\d+,\d+,\d+>|\r)/g, '')
if (str.startsWith('\ufeff[id:$00000000]')) str = str.replace('\ufeff[id:$00000000]\n', '')
let trans = str.match(/\[language:([\w=\\/+]+)\]/)
let tlyric
if (trans) {