跳过空白歌词

This commit is contained in:
lyswhut
2022-04-10 22:25:25 +08:00
parent 1c542a9b17
commit e75863e99d
3 changed files with 8 additions and 7 deletions
+3 -3
View File
@@ -153,6 +153,7 @@ const getPic = function(musicInfo, retryedSource = [], originMusic) {
})
}
const existTimeExp = /\[\d{1,2}:.*\d{1,4}\]/
const handleGetLyric = function(musicInfo, retryedSource = [], originMusic) {
if (!originMusic) originMusic = musicInfo
let reqPromise
@@ -162,8 +163,7 @@ const handleGetLyric = function(musicInfo, retryedSource = [], originMusic) {
reqPromise = Promise.reject(err)
}
return reqPromise.then(lyricInfo => {
if (!lyricInfo.lyric.trim()) return Promise.reject(new Error('failed'))
return lyricInfo
return existTimeExp.test(lyricInfo.lyric) ? lyricInfo : Promise.reject(new Error('failed'))
}).catch(err => {
// console.log(err)
if (!retryedSource.includes(musicInfo.source)) retryedSource.push(musicInfo.source)
@@ -184,7 +184,7 @@ const handleGetLyric = function(musicInfo, retryedSource = [], originMusic) {
const getLyric = function(musicInfo, isUseOtherSource, isS2t) {
return getLyricFromStorage(musicInfo).then(lrcInfo => {
return (
lrcInfo.lyric && lrcInfo.lyric.trim()
existTimeExp.test(lrcInfo.lyric)
? Promise.resolve({ lyric: lrcInfo.lyric, tlyric: lrcInfo.tlyric || '' })
: (
isUseOtherSource
+3 -3
View File
@@ -150,6 +150,7 @@ const getPic = function(musicInfo, retryedSource = [], originMusic) {
})
})
}
const existTimeExp = /\[\d{1,2}:.*\d{1,4}\]/
const getLyric = function(musicInfo, retryedSource = [], originMusic) {
if (!originMusic) originMusic = musicInfo
let reqPromise
@@ -159,8 +160,7 @@ const getLyric = function(musicInfo, retryedSource = [], originMusic) {
reqPromise = Promise.reject(err)
}
return reqPromise.then(lyricInfo => {
if (!lyricInfo.lyric.trim()) return Promise.reject(new Error('failed'))
return lyricInfo
return existTimeExp.test(lyricInfo.lyric) ? lyricInfo : Promise.reject(new Error('failed'))
}).catch(err => {
if (!retryedSource.includes(musicInfo.source)) retryedSource.push(musicInfo.source)
return this.dispatch('list/getOtherSource', originMusic).then(otherSource => {
@@ -216,7 +216,7 @@ const actions = {
const lrcInfo = await getStoreLyric(musicInfo)
// lrcInfo = {}
// if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp()
if (lrcInfo.lyric && lrcInfo.lyric.trim() && lrcInfo.tlyric != null) {
if (existTimeExp.test(lrcInfo.lyric) && lrcInfo.tlyric != 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, lxlyric: musicInfo.tlrc })