mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-03-21 19:13:10 +00:00
Compare commits
5 Commits
a9332af453
...
b6a1f9ce0a
| Author | SHA1 | Date | |
|---|---|---|---|
| b6a1f9ce0a | |||
|
|
5991e41c5d | ||
|
|
266cd8d059 | ||
|
|
89a70b14d4 | ||
|
|
59241631db |
53
module/song_url_v1_302.js
Normal file
53
module/song_url_v1_302.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// 获取客户端歌曲下载链接 - v1
|
||||||
|
// 此版本不再采用 br 作为音质区分的标准
|
||||||
|
// 而是采用 standard, exhigh, lossless, hires, jyeffect(高清环绕声), sky(沉浸环绕声), jymaster(超清母带) 进行音质判断
|
||||||
|
|
||||||
|
const createOption = require('../util/option.js')
|
||||||
|
module.exports = async (query, request) => {
|
||||||
|
const data = {
|
||||||
|
id: query.id,
|
||||||
|
immerseType: 'c51',
|
||||||
|
level: query.level,
|
||||||
|
}
|
||||||
|
const response = await request(
|
||||||
|
`/api/song/enhance/download/url/v1`,
|
||||||
|
data,
|
||||||
|
createOption(query),
|
||||||
|
)
|
||||||
|
let url = response?.body?.data?.[0]?.url
|
||||||
|
|
||||||
|
if (!url) {
|
||||||
|
const fallbackData = {
|
||||||
|
ids: `[${query.id}]`,
|
||||||
|
level: query.level,
|
||||||
|
encodeType: 'flac',
|
||||||
|
}
|
||||||
|
if (query.level === 'sky') {
|
||||||
|
fallbackData.immerseType = 'c51'
|
||||||
|
}
|
||||||
|
const fallback = await request(
|
||||||
|
`/api/song/enhance/player/url/v1`,
|
||||||
|
fallbackData,
|
||||||
|
createOption(query),
|
||||||
|
)
|
||||||
|
url = fallback?.body?.data?.[0]?.url
|
||||||
|
|
||||||
|
if (!url) {
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
status: 302,
|
||||||
|
body: '',
|
||||||
|
cookie: fallback.cookie || [],
|
||||||
|
redirectUrl: url,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
status: 302,
|
||||||
|
body: '',
|
||||||
|
cookie: response.cookie || [],
|
||||||
|
redirectUrl: url,
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1254,6 +1254,21 @@ tags: 歌单标签
|
|||||||
|
|
||||||
说明:`杜比全景声`音质需要设备支持,不同的设备可能会返回不同码率的 url。cookie 需要传入`os=pc`保证返回正常码率的 url。
|
说明:`杜比全景声`音质需要设备支持,不同的设备可能会返回不同码率的 url。cookie 需要传入`os=pc`保证返回正常码率的 url。
|
||||||
|
|
||||||
|
### 302到音乐 url - 新版
|
||||||
|
|
||||||
|
说明 : 只允许传入单个`id`,会使用302重定向请求到目标url
|
||||||
|
|
||||||
|
**必选参数 :** `id` : 音乐 id
|
||||||
|
`level`: 播放音质等级, 分为 `standard` => `标准`,`higher` => `较高`, `exhigh`=>`极高`,
|
||||||
|
`lossless`=>`无损`, `hires`=>`Hi-Res`, `jyeffect` => `高清环绕声`, `sky` => `沉浸环绕声`, `dolby` => `杜比全景声`, `jymaster` => `超清母带`
|
||||||
|
`unblock`: 是否使用使用歌曲解锁, 分为`true`和`false`
|
||||||
|
|
||||||
|
**接口地址 :** `/song/url/v1/302`
|
||||||
|
|
||||||
|
**调用例子 :** `/song/url/v1/302?id=1969519579&level=exhigh`
|
||||||
|
|
||||||
|
说明:`杜比全景声`音质需要设备支持,不同的设备可能会返回不同码率的 url。cookie 需要传入`os=pc`保证返回正常码率的 url。
|
||||||
|
|
||||||
### 音乐是否可用
|
### 音乐是否可用
|
||||||
|
|
||||||
说明: 调用此接口,传入歌曲 id, 可获取音乐是否可用,返回 `{ success: true, message: 'ok' }` 或者 `{ success: false, message: '亲爱的,暂无版权' }`
|
说明: 调用此接口,传入歌曲 id, 可获取音乐是否可用,返回 `{ success: true, message: 'ok' }` 或者 `{ success: false, message: '亲爱的,暂无版权' }`
|
||||||
|
|||||||
@ -221,7 +221,7 @@ async function consturctServer(moduleDefs) {
|
|||||||
|
|
||||||
for (const moduleDef of moduleDefinitions) {
|
for (const moduleDef of moduleDefinitions) {
|
||||||
// Register the route.
|
// Register the route.
|
||||||
app.use(moduleDef.route, async (req, res) => {
|
app.all(moduleDef.route, async (req, res) => {
|
||||||
;[req.query, req.body].forEach((item) => {
|
;[req.query, req.body].forEach((item) => {
|
||||||
// item may be undefined (some environments / middlewares).
|
// item may be undefined (some environments / middlewares).
|
||||||
// Guard access to avoid "Cannot read properties of undefined (reading 'cookie')".
|
// Guard access to avoid "Cannot read properties of undefined (reading 'cookie')".
|
||||||
@ -308,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)
|
res.status(moduleResponse.status).send(moduleResponse.body)
|
||||||
} catch (/** @type {*} */ moduleResponse) {
|
} catch (/** @type {*} */ moduleResponse) {
|
||||||
logger.error(`${decode(req.originalUrl)}`, {
|
logger.error(`${decode(req.originalUrl)}`, {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user