Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
重定向接口尝试
Browse files Browse the repository at this point in the history
因为nodejs版本太高本地无法测试
  • Loading branch information
Dreamkaka committed Feb 2, 2024
1 parent 1e46393 commit 873ffa2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
51 changes: 51 additions & 0 deletions module/song_url_redit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const request = require('request') // 或者 const axios = require('axios')

module.exports = async (query, request) => {
query.cookie.os = 'android'
query.cookie.appver = '8.10.05'
const data = {
ids: '[' + query.id + ']',
level: query.level,
encodeType: 'flac',
}
if (data.level == 'sky') {
data.immerseType = 'c51'
}

// 发送POST请求
const response = await request(
'POST',
`https://interface.music.163.com/eapi/song/enhance/player/url/v1`,
data,
{
crypto: 'eapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
url: '/api/song/enhance/player/url/v1',
},
)

// 从响应中获取URL
const url = response.data[0].url

// 使用request库进行重定向
const redirectResponse = await new Promise((resolve, reject) => {
request(url, (error, redirectResponse) => {
if (error) {
reject(error)
} else {
resolve(redirectResponse)
}
})
})

// 获取最终重定向后的URL
const redirectedUrl = redirectResponse.request.uri.href

// 将重定向后的URL添加到原始数据中
response.data[0].redirectedUrl = redirectedUrl

// 返回修改后的响应数据
return response
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 873ffa2

Please sign in to comment.