优化歌词自动换源机制

pull/733/head
lyswhut 2021-11-28 01:54:45 +08:00
parent 63141c4ac9
commit b6f885b250
5 changed files with 7 additions and 10 deletions

View File

@ -1,6 +1,3 @@
### 修复
### 优化
- 修复设置-控制按钮位置选项与下载歌词编码格式选项命名冲突导致选项显示异常的问题
- 修复播放下载列表时存在失效的歌曲会导致切歌不准确的问题
- 修复潜在的音乐加载超时不会切歌的问题
- 修复因kw源歌词接口停用导致该源歌词获取失败的问题
- 优化歌词自动换源机制

View File

@ -125,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: null, tlyric: null, lxlyric: null }
if (!result) return Promise.reject(new Error('Get lyric failed'))
let requestObj2 = this.getLyricDownload(result.id, result.accessKey)

View File

@ -25,8 +25,8 @@ export default {
},
})
requestObj.promise = requestObj.promise.then(({ body }) => {
if (body.returnCode !== '000000') {
if (tryNum > 5) return Promise.reject('歌词获取失败')
if (body.returnCode !== '000000' || !body.lyric) {
if (tryNum > 5) return Promise.reject(new Error('Get lyric failed'))
let tryRequestObj = this.getLyric(songInfo, ++tryNum)
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
return tryRequestObj.promise

View File

@ -12,7 +12,7 @@ export default {
},
})
requestObj.promise = requestObj.promise.then(({ body }) => {
if (body.code != 0) return Promise.reject(new Error('获取歌词失败'))
if (body.code != 0 || !body.lyric) return Promise.reject(new Error('Get lyric failed'))
return {
lyric: decodeName(b64DecodeUnicode(body.lyric)),
tlyric: decodeName(b64DecodeUnicode(body.trans)),

View File

@ -50,7 +50,7 @@ export default songmid => {
}),
})
requestObj.promise = requestObj.promise.then(({ body }) => {
if (body.code !== 200) return Promise.reject('获取歌词失败')
if (body.code !== 200 || !body?.lrc?.lyric) return Promise.reject(new Error('Get lyric failed'))
return {
lyric: body.lrc.lyric,
tlyric: body.tlyric.lyric,