mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-20 14:41:23 +08:00
feat: add song download url api end point for 302
* This will redirect access from http://localhost:3000/song/url/v1?id=2756058128&level=exhigh to actual resource url
This commit is contained in:
@@ -210,6 +210,7 @@ async function consturctServer(moduleDefs) {
|
||||
'daily_signin.js': '/daily_signin',
|
||||
'fm_trash.js': '/fm_trash',
|
||||
'personal_fm.js': '/personal_fm',
|
||||
'song_download_url_v1_302.js': '/song/url/v1/302',
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,7 +222,7 @@ async function consturctServer(moduleDefs) {
|
||||
|
||||
for (const moduleDef of moduleDefinitions) {
|
||||
// Register the route.
|
||||
app.use(moduleDef.route, async (req, res) => {
|
||||
app.all(moduleDef.route, async (req, res) => {
|
||||
;[req.query, req.body].forEach((item) => {
|
||||
// item may be undefined (some environments / middlewares).
|
||||
// Guard access to avoid "Cannot read properties of undefined (reading 'cookie')".
|
||||
@@ -307,6 +308,11 @@ async function consturctServer(moduleDefs) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (moduleResponse.redirectUrl) {
|
||||
res.redirect(moduleResponse.status || 302, moduleResponse.redirectUrl)
|
||||
return
|
||||
}
|
||||
|
||||
res.status(moduleResponse.status).send(moduleResponse.body)
|
||||
} catch (/** @type {*} */ moduleResponse) {
|
||||
logger.error(`${decode(req.originalUrl)}`, {
|
||||
|
||||
Reference in New Issue
Block a user