优化kw源英文与翻译歌词的匹配

This commit is contained in:
lyswhut 2022-01-26 17:49:13 +08:00
parent ca417c8b38
commit 5615c706a9
2 changed files with 21 additions and 21 deletions

View File

@ -1,7 +1,3 @@
### 修复
### 优化
- 修复某些系统下的虚拟导航栏会导致播放栏隐藏的问题react-native v0.67.x导致的
### 其他
- 降级react-native到 v0.66.4
- 优化kw源英文与翻译歌词的匹配

View File

@ -14,22 +14,20 @@ export default {
for (const item of arr) {
if (lrcSet.has(item.time)) {
const tItem = lrc.pop()
tItem.time = lrc[lrc.length - 1].time
lrcT.push(tItem)
lrc.push(item)
} else {
lrcT.push(item)
lrc.push(item)
lrcSet.add(item.time)
}
}
if (lrc.length) {
if ((lrcT.length - lrc.length) > (lrcT.length * 0.1)) { // 翻译比正文多则证明翻译可能有问题,直接将其丢弃
lrc = lrcT
lrcT = []
} else {
lrc.unshift(lrcT.shift())
}
} else {
lrc = lrcT
lrcT = []
if (lrcT.length && lrc.length > lrcT.length) {
const tItem = lrc.pop()
tItem.time = lrc[lrc.length - 1].time
lrcT.push(tItem)
}
return {
@ -45,16 +43,22 @@ export default {
requestObj.promise = requestObj.promise.then(({ body }) => {
// console.log(body)
if (!body.data?.lrclist?.length) return Promise.reject(new Error('Get lyric failed'))
const { lrc, lrcT } = this.sortLrcArr(body.data.lrclist)
let lrcInfo
try {
lrcInfo = this.sortLrcArr(body.data.lrclist)
} catch (err) {
console.log(err)
return Promise.reject(new Error('Get lyric failed'))
}
// console.log(body.data.lrclist)
// console.log(lrc, lrcT)
// console.log(lrcInfo.lrc, lrcInfo.lrcT)
// console.log({
// lyric: decodeName(this.transformLrc(body.data.songinfo, lrc)),
// tlyric: decodeName(this.transformLrc(body.data.songinfo, lrcT)),
// })
return {
lyric: decodeName(this.transformLrc(body.data.songinfo, lrc)),
tlyric: lrcT.length ? decodeName(this.transformLrc(body.data.songinfo, lrcT)) : '',
lyric: decodeName(this.transformLrc(body.data.songinfo, lrcInfo.lrc)),
tlyric: lrcInfo.lrcT.length ? decodeName(this.transformLrc(body.data.songinfo, lrcInfo.lrcT)) : '',
}
})
return requestObj