初步完善歌词

This commit is contained in:
lyswhut
2021-03-02 08:32:26 +08:00
parent 9f72831e4a
commit 040fcfba4f
12 changed files with 779 additions and 120 deletions
+11 -5
View File
@@ -2,10 +2,13 @@ import { httpFetch } from '../../request'
import { decodeLyric } from './util'
import { decodeName } from '../..'
const headExp = /^.*\[id:\$00000000\]\n/
const parseLyric = str => {
str = str.replace(/(?:<\d+,\d+,\d+>|\r)/g, '')
if (str.startsWith('\ufeff[id:$00000000]')) str = str.replace('\ufeff[id:$00000000]\n', '')
str = str.replace(/\r/g, '')
if (headExp.test(str)) str = str.replace(headExp, '')
let trans = str.match(/\[language:([\w=\\/+]+)\]/)
let lyric
let tlyric
if (trans) {
str = str.replace(/\[language:[\w=\\/+]+\]\n/, '')
@@ -18,7 +21,7 @@ const parseLyric = str => {
}
}
let i = 0
let lyric = str.replace(/\[((\d+),\d+)\].*/g, str => {
let lxlyric = str.replace(/\[((\d+),\d+)\].*/g, str => {
let result = str.match(/\[((\d+),\d+)\].*/)
let time = parseInt(result[2])
let ms = time % 1000
@@ -31,11 +34,14 @@ const parseLyric = str => {
return str.replace(result[1], time)
})
tlyric = tlyric ? tlyric.join('\n') : ''
lyric = decodeName(lyric)
lxlyric = lxlyric.replace(/<(\d+,\d+),\d+>/g, '<$1>')
lxlyric = decodeName(lxlyric)
lyric = lxlyric.replace(/<\d+,\d+>/g, '')
tlyric = decodeName(tlyric)
return {
lyric,
tlyric,
lxlyric,
}
}
@@ -119,7 +125,7 @@ export default {
let requestObj = this.searchLyric(songInfo.name, songInfo.hash, songInfo._interval || this.getIntv(songInfo.interval))
requestObj.promise = requestObj.promise.then(result => {
if (!result) return { lyric: '', tlyric: '' }
if (!result) return { lyric: '', tlyric: '', lxlyric: '' }
let requestObj2 = this.getLyricDownload(result.id, result.accessKey)
+3 -1
View File
@@ -20,7 +20,9 @@ const wy = {
return getLyric(songInfo.songmid)
},
getPic(songInfo) {
return getMusicInfo(songInfo.songmid).then(info => info.al.picUrl)
const requestObj = getMusicInfo(songInfo.songmid)
requestObj.promise = requestObj.promise.then(info => info.al.picUrl)
return requestObj
},
getMusicDetailPageUrl(songInfo) {
return `https://music.163.com/#/song?id=${songInfo.songmid}`