原接口已挂,暂时切换到临时接口

This commit is contained in:
lyswhut
2019-08-17 21:43:53 +08:00
parent 214745ae87
commit 6e07719c2c
9 changed files with 113 additions and 37 deletions
+9 -5
View File
@@ -56,16 +56,18 @@ const kw = {
let cancelFn
const p = new Promise((resolve, reject) => {
cancelFn = reject
requestObj = httpGet(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, (err, resp, body) => {
// requestObj = httpGet(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, (err, resp, body) => {
requestObj = httpGet(`https://www.stsky.cn/api/temp/getMusicUrl.php?id=${songInfo.songmid}&type=${type}`, (err, resp, body) => {
requestObj = null
cancelFn = null
if (err) {
console.log(err)
if (err.message === 'socket hang up') return reject(new Error('接口挂了'))
const { promise, cancelHttp } = this.getMusicUrl(songInfo, type)
obj.cancelHttp = cancelHttp
return promise
}
body.code === 200 ? resolve({ type, url: body.data }) : reject(new Error(body.msg))
// body.code === 200 ? resolve({ type, url: body.data }) : reject(new Error(body.msg))
body.code === 0 ? resolve({ type, url: body.data }) : reject(new Error(body.msg))
})
})
const obj = {
@@ -123,14 +125,16 @@ const kw = {
}
return new Promise((resolve, reject) => {
this._musicPicPromiseCancelFn = reject
this._musicPicRequestObj = httpGet(`https://v1.itooi.cn/kuwo/pic?id=${songInfo.songmid}&isRedirect=0`, (err, resp, body) => {
// this._musicPicRequestObj = httpGet(`https://v1.itooi.cn/kuwo/pic?id=${songInfo.songmid}&isRedirect=0`, (err, resp, body) => {
this._musicPicRequestObj = httpGet(`https://www.stsky.cn/api/temp/getPic.php?size=320&songmid=${songInfo.songmid}`, (err, resp, body) => {
this._musicPicRequestObj = null
this._musicPicPromiseCancelFn = null
if (err) {
console.log(err)
reject(err)
}
body.code === 200 ? resolve(body.data) : reject(new Error(body.msg))
// body.code === 200 ? resolve(body.data) : reject(new Error(body.msg))
body.code === 0 ? resolve(body.data) : reject(new Error(body.msg))
})
})
},
+7 -4
View File
@@ -8,6 +8,9 @@ export default {
let s = (time % 60).toFixed(2)
return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s)
},
transformLrc({ songinfo, lrclist }) {
return `[ti:${songinfo.songName}]\n[ar:${songinfo.artist}]\n[al:${songinfo.album}]\n[by:]\n[offset:0]\n${lrclist ? lrclist.map(l => `[${this.formatTime(l.time)}]${l.lineLyric}\n`).join('') : '暂无歌词'}`
},
getLyric(songId) {
if (this._musicLrcRequestObj != null) {
cancelHttp(this._musicLrcRequestObj)
@@ -15,16 +18,16 @@ export default {
}
return new Promise((resolve, reject) => {
this._musicLrcPromiseCancelFn = reject
this._musicLrcRequestObj = httpGet(`https://v1.itooi.cn/kuwo/lrc?id=${songId}`, (err, resp, body) => {
// this._musicLrcRequestObj = httpGet(`https://v1.itooi.cn/kuwo/lrc?id=${songId}`, (err, resp, body) => {
this._musicLrcRequestObj = httpGet(`http://m.kuwo.cn/newh5/singles/songinfoandlrc?musicId=${songId}`, (err, resp, body) => {
this._musicLrcRequestObj = null
this._musicLrcPromiseCancelFn = null
if (err) {
console.log(err)
reject(err)
}
// console.log(body.data)
// console.log(this.transformLrc(body.data))
resolve(body)
// resolve(body)
resolve(this.transformLrc(body.data))
})
})
},