mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-03 18:42:09 +08:00
支持mg源的歌词翻译
This commit is contained in:
parent
d54ea29837
commit
b907eb652a
@ -3,6 +3,10 @@
|
|||||||
- 新增设置-桌面歌词-单行歌词设置,默认关闭,启用后只显示一行歌词,超出窗口宽度自动滚动到末尾
|
- 新增设置-桌面歌词-单行歌词设置,默认关闭,启用后只显示一行歌词,超出窗口宽度自动滚动到末尾
|
||||||
- 新增设置-桌面歌词-显示歌词切换动画,默认启用,如果你觉得切换动画影响视觉可以将其关闭
|
- 新增设置-桌面歌词-显示歌词切换动画,默认启用,如果你觉得切换动画影响视觉可以将其关闭
|
||||||
|
|
||||||
|
### 优化
|
||||||
|
|
||||||
|
- 支持mg源的歌词翻译(之前添加的歌曲需要去设置清空缓存才会刷新歌词)
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
- 修复桌面歌词转繁体设置不立即生效的问题
|
- 修复桌面歌词转繁体设置不立即生效的问题
|
||||||
|
@ -148,6 +148,8 @@ export default {
|
|||||||
img: item.albumImgs && item.albumImgs.length ? item.albumImgs[0].img : null,
|
img: item.albumImgs && item.albumImgs.length ? item.albumImgs[0].img : null,
|
||||||
lrc: null,
|
lrc: null,
|
||||||
lrcUrl: item.lrcUrl,
|
lrcUrl: item.lrcUrl,
|
||||||
|
mrcUrl: item.mrcUrl,
|
||||||
|
trcUrl: item.trcUrl,
|
||||||
otherSource: null,
|
otherSource: null,
|
||||||
types,
|
types,
|
||||||
_types,
|
_types,
|
||||||
|
@ -1,23 +1,50 @@
|
|||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
|
import musicSearch from './musicSearch'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
getText(url, tryNum = 0) {
|
||||||
|
const requestObj = httpFetch(url, {
|
||||||
|
headers: {
|
||||||
|
Referer: 'https://app.c.nf.migu.cn/',
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Mobile Safari/537.36',
|
||||||
|
channel: '0146921',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return requestObj.promise.then(({ statusCode, body }) => {
|
||||||
|
if (statusCode == 200) return body
|
||||||
|
if (tryNum > 5 || statusCode == 404) return Promise.reject('歌词获取失败')
|
||||||
|
return this.getText(url, ++tryNum)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getLrc(url) {
|
||||||
|
return this.getText(url)
|
||||||
|
},
|
||||||
|
getTrc(url) {
|
||||||
|
if (!url) return Promise.resolve('')
|
||||||
|
return this.getText(url)
|
||||||
|
},
|
||||||
|
getMusicInfo(songInfo) {
|
||||||
|
return songInfo.mrcUrl == null
|
||||||
|
? musicSearch.search(`${songInfo.name} ${songInfo.singer || ''}`.trim(), 1, { limit: 25 }).then(({ list }) => {
|
||||||
|
const targetSong = list.find(s => s.songmid == songInfo.songmid)
|
||||||
|
return targetSong ? { lrcUrl: targetSong.lrcUrl, mrcUrl: targetSong.mrcUrl, trcUrl: targetSong.trcUrl } : Promise.reject('获取歌词失败')
|
||||||
|
})
|
||||||
|
: Promise.resolve({ lrcUrl: songInfo.lrcUrl, mrcUrl: songInfo.mrcUrl, trcUrl: songInfo.trcUrl })
|
||||||
|
},
|
||||||
getLyric(songInfo, tryNum = 0) {
|
getLyric(songInfo, tryNum = 0) {
|
||||||
// console.log(songInfo.copyrightId)
|
// console.log(songInfo.copyrightId)
|
||||||
if (songInfo.lrcUrl) {
|
if (songInfo.lrcUrl) {
|
||||||
let requestObj = httpFetch(songInfo.lrcUrl)
|
return {
|
||||||
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
promise: this.getMusicInfo(songInfo).then(info => {
|
||||||
if (statusCode !== 200) {
|
return Promise.all([this.getLrc(info.lrcUrl), this.getTrc(info.trcUrl)]).then(([lyric, tlyric]) => {
|
||||||
if (tryNum > 5) return Promise.reject('歌词获取失败')
|
return {
|
||||||
let tryRequestObj = this.getLyric(songInfo, ++tryNum)
|
lyric,
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
tlyric,
|
||||||
return tryRequestObj.promise
|
}
|
||||||
}
|
})
|
||||||
return {
|
}),
|
||||||
lyric: body,
|
cancelHttp() {},
|
||||||
tlyric: '',
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
return requestObj
|
|
||||||
} else {
|
} else {
|
||||||
let requestObj = httpFetch(`http://music.migu.cn/v3/api/music/audioPlayer/getLyric?copyrightId=${songInfo.copyrightId}`, {
|
let requestObj = httpFetch(`http://music.migu.cn/v3/api/music/audioPlayer/getLyric?copyrightId=${songInfo.copyrightId}`, {
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -89,7 +89,7 @@ export default {
|
|||||||
name: item.name,
|
name: item.name,
|
||||||
albumName: albumNInfo.name,
|
albumName: albumNInfo.name,
|
||||||
albumId: albumNInfo.id,
|
albumId: albumNInfo.id,
|
||||||
songmid: item.id,
|
songmid: item.copyrightId,
|
||||||
songId: item.songId,
|
songId: item.songId,
|
||||||
copyrightId: item.copyrightId,
|
copyrightId: item.copyrightId,
|
||||||
source: 'mg',
|
source: 'mg',
|
||||||
@ -97,6 +97,8 @@ export default {
|
|||||||
img: item.imgItems && item.imgItems.length ? item.imgItems[0].img : null,
|
img: item.imgItems && item.imgItems.length ? item.imgItems[0].img : null,
|
||||||
lrc: null,
|
lrc: null,
|
||||||
lrcUrl: item.lyricUrl,
|
lrcUrl: item.lyricUrl,
|
||||||
|
mrcUrl: item.mrcurl,
|
||||||
|
trcUrl: item.trcUrl,
|
||||||
otherSource: null,
|
otherSource: null,
|
||||||
types,
|
types,
|
||||||
_types,
|
_types,
|
||||||
|
@ -214,6 +214,8 @@ export default {
|
|||||||
img: item.albumImgs && item.albumImgs.length ? item.albumImgs[0].img : null,
|
img: item.albumImgs && item.albumImgs.length ? item.albumImgs[0].img : null,
|
||||||
lrc: null,
|
lrc: null,
|
||||||
lrcUrl: item.lrcUrl,
|
lrcUrl: item.lrcUrl,
|
||||||
|
mrcUrl: item.mrcUrl,
|
||||||
|
trcUrl: item.trcUrl,
|
||||||
otherSource: null,
|
otherSource: null,
|
||||||
types,
|
types,
|
||||||
_types,
|
_types,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user