跳过空白歌词
parent
1c542a9b17
commit
e75863e99d
|
@ -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
|
||||
|
|
|
@ -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 })
|
||||
|
|
|
@ -91,6 +91,7 @@ const buildParams = (id, isGetLyricx) => {
|
|||
// console.log(buildParams('207527604', true))
|
||||
|
||||
const timeExp = /^\[([\d:.]*)\]{1}/g
|
||||
const existTimeExp = /\[\d{1,2}:.*\d{1,4}\]/
|
||||
export default {
|
||||
sortLrcArr(arr) {
|
||||
const lrcSet = new Set()
|
||||
|
@ -201,7 +202,7 @@ export default {
|
|||
lrcInfo.lxlyric = ''
|
||||
}
|
||||
lrcInfo.lyric = lrcInfo.lyric.replace(lrcTools.rxps.wordTimeAll, '')
|
||||
if (!lrcInfo.lyric.trim()) return Promise.reject(new Error('Get lyric failed'))
|
||||
if (!existTimeExp.test(lrcInfo.lyric)) return Promise.reject(new Error('Get lyric failed'))
|
||||
// console.log(lrcInfo)
|
||||
return lrcInfo
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue