修复 mg 图片、歌词获取
This commit is contained in:
@@ -75,7 +75,7 @@ const mrcTools = {
|
||||
},
|
||||
async getMusicInfo(songInfo) {
|
||||
return songInfo.mrcUrl == null
|
||||
? getMusicInfo(songInfo.copyrightId)
|
||||
? getMusicInfo(songInfo.songmid)
|
||||
: songInfo
|
||||
},
|
||||
getLyric(songInfo) {
|
||||
|
||||
@@ -1,28 +1,8 @@
|
||||
import { httpFetch } from '../../request'
|
||||
import getSongId from './songId'
|
||||
import { getMusicInfo } from './musicInfo'
|
||||
|
||||
export default {
|
||||
async getPicUrl(songId, tryNum = 0) {
|
||||
let requestObj = httpFetch(`http://music.migu.cn/v3/api/music/audioPlayer/getSongPic?songId=${songId}`, {
|
||||
headers: {
|
||||
Referer: 'http://music.migu.cn/v3/music/player/audio?from=migu',
|
||||
},
|
||||
})
|
||||
requestObj.promise.then(({ body }) => {
|
||||
if (body.returnCode !== '000000') {
|
||||
if (tryNum > 5) return Promise.reject(new Error('图片获取失败'))
|
||||
let tryRequestObj = this.getPic(songId, ++tryNum)
|
||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||
return tryRequestObj.promise
|
||||
}
|
||||
let url = body.largePic || body.mediumPic || body.smallPic
|
||||
if (!/https?:/.test(url)) url = 'http:' + url
|
||||
return url
|
||||
})
|
||||
return requestObj
|
||||
},
|
||||
async getPic(songInfo) {
|
||||
const songId = await getSongId(songInfo)
|
||||
return this.getPicUrl(songId)
|
||||
const info = await getMusicInfo(songInfo.songmid)
|
||||
return info.img
|
||||
},
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getMusicInfo } from './musicInfo'
|
||||
|
||||
const getSongId = async(mInfo) => {
|
||||
if (mInfo.songmid != mInfo.copyrightId) return mInfo.songmid
|
||||
const musicInfo = await getMusicInfo(mInfo.copyrightId)
|
||||
const musicInfo = await getMusicInfo(mInfo.songmid)
|
||||
return musicInfo.songmid
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user