This commit is contained in:
Folltoshe 2023-06-10 13:54:56 +08:00
parent b0624be9b5
commit d735b7ac1e
2 changed files with 3 additions and 15 deletions

View File

@ -43,7 +43,7 @@ export default {
},
},
}).then(body => {
if (body.req_1 != 0 || body.req_2 != 0 || body.req_3 != 0) throw new Error('get singer info faild.')
if (!body.req_1 || !body.req_2 || !body.req_3) throw new Error('get singer info faild.')
const info = body.req_1.singer_list[0]
const music = body.req_3

View File

@ -1,17 +1,6 @@
import { httpFetch } from '../../../request'
import { eapi } from './crypto'
const buildEapiRequest = (formData) => {
return httpFetch('http://interface.music.163.com/eapi/batch', {
method: 'POST',
headers: {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
origin: 'https://music.163.com',
},
form: formData,
})
}
export const eapiRequest = (url, data) => {
return httpFetch('http://interface.music.163.com/eapi/batch', {
method: 'post',
@ -33,18 +22,17 @@ export const eapiRequest = (url, data) => {
}
/**
* 创建一个适用于WY的Eapi请求
* 创建一个Eapi请求
* @param {*} url
* @param {*} options
* @param {*} retryNum
*/
export const createEapiFetch = async(url, data, retryNum = 0) => {
if (retryNum > 2) throw new Error('try max num')
const formData = eapi(url, data)
let result
try {
result = await buildEapiRequest(formData).promise
result = await eapiRequest(url, data).promise
} catch (err) {
console.log(err)
return createEapiFetch(url, data, ++retryNum)