分离歌词与歌曲列表信息的保存
This commit is contained in:
@@ -646,10 +646,10 @@ export default {
|
||||
}
|
||||
},
|
||||
setLrc(targetSong) {
|
||||
this.getLrc(targetSong).then(() => {
|
||||
this.musicInfo.lrc = targetSong.lrc
|
||||
this.musicInfo.tlrc = targetSong.tlrc
|
||||
this.musicInfo.lxlrc = targetSong.lxlrc
|
||||
this.getLrc(targetSong).then(({ lyric, tlyric, lxlyric }) => {
|
||||
this.musicInfo.lrc = lyric
|
||||
this.musicInfo.tlrc = tlyric
|
||||
this.musicInfo.lxlrc = lxlyric
|
||||
}).catch(() => {
|
||||
this.status = this.statusText = this.$t('core.player.lyric_error')
|
||||
}).finally(() => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import fs from 'fs'
|
||||
import path from 'path'
|
||||
import music from '../../utils/music'
|
||||
import { getMusicType } from '../../utils/music/utils'
|
||||
import { setMeta, saveLrc } from '../../utils'
|
||||
import { setMeta, saveLrc, getLyric, setLyric } from '../../utils'
|
||||
|
||||
// state
|
||||
const state = {
|
||||
@@ -179,12 +179,17 @@ const saveMeta = (downloadInfo, filePath, isEmbedPic, isEmbedLyric) => {
|
||||
})
|
||||
: Promise.resolve(),
|
||||
isEmbedLyric
|
||||
? downloadInfo.musicInfo.lrc
|
||||
? Promise.resolve({ lyric: downloadInfo.musicInfo.lrc, tlyric: downloadInfo.musicInfo.tlrc || '' })
|
||||
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise.catch(err => {
|
||||
console.log(err)
|
||||
return null
|
||||
})
|
||||
? getLyric(downloadInfo.musicInfo).then(lrcInfo => {
|
||||
return lrcInfo.lyric
|
||||
? Promise.resolve({ lyric: lrcInfo.lyric, tlyric: lrcInfo.tlyric || '' })
|
||||
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise.then(({ lyric, tlyric, lxlyric }) => {
|
||||
setLyric(downloadInfo.musicInfo, { lyric, tlyric, lxlyric })
|
||||
return { lyric, tlyric, lxlyric }
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
return null
|
||||
})
|
||||
})
|
||||
: Promise.resolve(),
|
||||
]
|
||||
Promise.all(tasks).then(([imgUrl, lyrics = {}]) => {
|
||||
@@ -205,9 +210,14 @@ const saveMeta = (downloadInfo, filePath, isEmbedPic, isEmbedLyric) => {
|
||||
* @param {*} filePath
|
||||
*/
|
||||
const downloadLyric = (downloadInfo, filePath) => {
|
||||
const promise = downloadInfo.musicInfo.lrc
|
||||
? Promise.resolve({ lyric: downloadInfo.musicInfo.lrc, tlyric: downloadInfo.musicInfo.tlrc || '' })
|
||||
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise
|
||||
const promise = getLyric(downloadInfo.musicInfo).then(lrcInfo => {
|
||||
return lrcInfo.lyric
|
||||
? Promise.resolve({ lyric: lrcInfo.lyric, tlyric: lrcInfo.tlyric || '' })
|
||||
: music[downloadInfo.musicInfo.source].getLyric(downloadInfo.musicInfo).promise.then(({ lyric, tlyric, lxlyric }) => {
|
||||
setLyric(downloadInfo.musicInfo, { lyric, tlyric, lxlyric })
|
||||
return { lyric, tlyric, lxlyric }
|
||||
})
|
||||
})
|
||||
promise.then(lrcs => {
|
||||
if (lrcs.lyric) {
|
||||
lrcs.lyric = fixKgLyric(lrcs.lyric)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import musicSdk from '../../utils/music'
|
||||
import { clearLyric } from '../../utils'
|
||||
|
||||
let allList = {}
|
||||
window.allList = allList
|
||||
@@ -207,9 +208,12 @@ const mutations = {
|
||||
if (item.typeUrl['320k']) delete item.typeUrl['320k']
|
||||
if (item.typeUrl.flac) delete item.typeUrl.flac
|
||||
if (item.typeUrl.wav) delete item.typeUrl.wav
|
||||
if (item.lxlrc) item.lxlrc = null
|
||||
if (item.lrc) item.lrc = null
|
||||
if (item.tlrc) item.tlrc = null
|
||||
clearLyric()
|
||||
|
||||
// v1.8.2以前的Lyric
|
||||
if (item.lxlrc) delete item.lxlrc
|
||||
if (item.lrc) delete item.lrc
|
||||
if (item.tlrc) delete item.tlrc
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from 'path'
|
||||
import music from '../../utils/music'
|
||||
import { getRandom, checkPath } from '../../utils'
|
||||
import { getRandom, checkPath, getLyric as getStoreLyric, setLyric } from '../../utils'
|
||||
|
||||
// state
|
||||
const state = {
|
||||
@@ -182,26 +182,26 @@ const actions = {
|
||||
return Promise.reject(err)
|
||||
})
|
||||
},
|
||||
getLrc({ commit, state }, musicInfo) {
|
||||
async getLrc({ commit, state }, musicInfo) {
|
||||
const lrcInfo = await getStoreLyric(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, lxlyric: musicInfo.tlrc })
|
||||
} else if (musicInfo.lrc.startsWith('[id:$00000000]')) {
|
||||
let str = musicInfo.lrc.replace('[id:$00000000]\n', '')
|
||||
commit('setLrc', { musicInfo, lyric: str, tlyric: musicInfo.tlrc, lxlyric: musicInfo.tlrc })
|
||||
}
|
||||
if (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 })
|
||||
// } else if (musicInfo.lrc.startsWith('[id:$00000000]')) {
|
||||
// let str = musicInfo.lrc.replace('[id:$00000000]\n', '')
|
||||
// commit('setLrc', { musicInfo, lyric: str, tlyric: musicInfo.tlrc, lxlyric: musicInfo.tlrc })
|
||||
// }
|
||||
|
||||
if ((musicInfo.lxlrc == null && musicInfo.source != 'kg') || musicInfo.lxlrc != null) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
if ((lrcInfo.lxlyric == null && musicInfo.source != 'kg') || lrcInfo.lxlyric != null) return lrcInfo
|
||||
}
|
||||
|
||||
// lrcRequest = music[musicInfo.source].getLyric(musicInfo)
|
||||
return getLyric.call(this, musicInfo).then(({ lyric, tlyric, lxlyric }) => {
|
||||
// lrcRequest = null
|
||||
commit('setLrc', { musicInfo, lyric, tlyric, lxlyric })
|
||||
return { lyric, tlyric, lxlyric }
|
||||
}).catch(err => {
|
||||
// lrcRequest = null
|
||||
return Promise.reject(err)
|
||||
@@ -338,6 +338,11 @@ const mutations = {
|
||||
datas.musicInfo.lrc = datas.lyric
|
||||
datas.musicInfo.tlrc = datas.tlyric
|
||||
datas.musicInfo.lxlrc = datas.lxlyric
|
||||
setLyric(datas.musicInfo, {
|
||||
lyric: datas.lyric,
|
||||
tlyric: datas.tlyric,
|
||||
lxlyric: datas.lxlyric,
|
||||
})
|
||||
},
|
||||
setList(state, { list, index }) {
|
||||
state.playMusicInfo = {
|
||||
|
||||
@@ -407,3 +407,10 @@ export const parseUrlParams = str => {
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
export const getLyric = musicInfo => rendererInvoke(NAMES.mainWindow.get_lyric, `${musicInfo.source}_${musicInfo.songmid}`)
|
||||
export const setLyric = (musicInfo, { lyric, tlyric, lxlyric }) => rendererSend(NAMES.mainWindow.save_lyric, {
|
||||
id: `${musicInfo.source}_${musicInfo.songmid}`,
|
||||
lyrics: { lyric, tlyric, lxlyric },
|
||||
})
|
||||
export const clearLyric = () => rendererSend(NAMES.mainWindow.clear_lyric)
|
||||
|
||||
Reference in New Issue
Block a user