mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-05-23 22:37:41 +08:00
feat: 增加下载、购买记录接口
This commit is contained in:
parent
a0d4a3c27a
commit
422722e0a7
@ -429,6 +429,9 @@ banner({ type: 0 }).then((res) => {
|
|||||||
283. 云盘导入歌曲
|
283. 云盘导入歌曲
|
||||||
284. 获取客户端歌曲下载链接 - 新版
|
284. 获取客户端歌曲下载链接 - 新版
|
||||||
285. 当前账号关注的用户/歌手
|
285. 当前账号关注的用户/歌手
|
||||||
|
286. 会员下载歌曲记录
|
||||||
|
287. 会员本月下载歌曲记录
|
||||||
|
288. 已购买单曲
|
||||||
|
|
||||||
## 单元测试
|
## 单元测试
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const { cookieToJson } = require('../util/index')
|
||||||
const createOption = require('../util/option.js')
|
const createOption = require('../util/option.js')
|
||||||
module.exports = (query, request) => {
|
module.exports = (query, request) => {
|
||||||
const method = query.method || 'POST'
|
const method = query.method || 'POST'
|
||||||
@ -6,6 +7,10 @@ module.exports = (query, request) => {
|
|||||||
try {
|
try {
|
||||||
data =
|
data =
|
||||||
typeof query.data === 'string' ? JSON.parse(query.data) : query.data || {}
|
typeof query.data === 'string' ? JSON.parse(query.data) : query.data || {}
|
||||||
|
if (typeof data.cookie === 'string') {
|
||||||
|
data.cookie = cookieToJson(data.cookie)
|
||||||
|
query.cookie = data.cookie
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
data = {}
|
data = {}
|
||||||
}
|
}
|
||||||
|
11
module/song_downlist.js
Normal file
11
module/song_downlist.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// 会员下载歌曲记录
|
||||||
|
|
||||||
|
const createOption = require('../util/option.js')
|
||||||
|
module.exports = (query, request) => {
|
||||||
|
const data = {
|
||||||
|
limit: query.limit || '20',
|
||||||
|
offset: query.offset || '0',
|
||||||
|
total: 'true',
|
||||||
|
}
|
||||||
|
return request('POST', `/api/member/song/downlist`, data, createOption(query))
|
||||||
|
}
|
16
module/song_monthdownlist.js
Normal file
16
module/song_monthdownlist.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// 会员本月下载歌曲记录
|
||||||
|
|
||||||
|
const createOption = require('../util/option.js')
|
||||||
|
module.exports = (query, request) => {
|
||||||
|
const data = {
|
||||||
|
limit: query.limit || '20',
|
||||||
|
offset: query.offset || '0',
|
||||||
|
total: 'true',
|
||||||
|
}
|
||||||
|
return request(
|
||||||
|
'POST',
|
||||||
|
`/api/member/song/monthdownlist`,
|
||||||
|
data,
|
||||||
|
createOption(query),
|
||||||
|
)
|
||||||
|
}
|
16
module/song_singledownlist.js
Normal file
16
module/song_singledownlist.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// 已购买单曲
|
||||||
|
|
||||||
|
const createOption = require('../util/option.js')
|
||||||
|
module.exports = (query, request) => {
|
||||||
|
const data = {
|
||||||
|
limit: query.limit || '20',
|
||||||
|
offset: query.offset || '0',
|
||||||
|
total: 'true',
|
||||||
|
}
|
||||||
|
return request(
|
||||||
|
'POST',
|
||||||
|
`/api/member/song/singledownlist`,
|
||||||
|
data,
|
||||||
|
createOption(query),
|
||||||
|
)
|
||||||
|
}
|
@ -112,7 +112,7 @@
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
uri: uri,
|
uri: uri,
|
||||||
data: data,
|
data: JSON.parse(data),
|
||||||
crypto: crypto,
|
crypto: crypto,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -301,6 +301,9 @@
|
|||||||
283. 云盘导入歌曲
|
283. 云盘导入歌曲
|
||||||
284. 获取客户端歌曲下载链接 - 新版
|
284. 获取客户端歌曲下载链接 - 新版
|
||||||
285. 当前账号关注的用户/歌手
|
285. 当前账号关注的用户/歌手
|
||||||
|
286. 会员下载歌曲记录
|
||||||
|
287. 会员本月下载歌曲记录
|
||||||
|
288. 已购买单曲
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
@ -4714,6 +4717,48 @@ bitrate = Math.floor(br / 1000)
|
|||||||
|
|
||||||
**调用例子 :** `/user/follow/mixed?scene=1`
|
**调用例子 :** `/user/follow/mixed?scene=1`
|
||||||
|
|
||||||
|
### 会员下载歌曲记录
|
||||||
|
|
||||||
|
说明 : 调用此接口, 可获得当前账号会员下载歌曲记录
|
||||||
|
|
||||||
|
**可选参数 :**
|
||||||
|
|
||||||
|
`limit` : 返回数量 , 默认为 20
|
||||||
|
|
||||||
|
`offset` : 偏移数量,用于分页 ,如 :( 页数 -1)\*30, 其中 30 为 limit 的值 , 默认为 0
|
||||||
|
|
||||||
|
**接口地址 :** `/song/downlist`
|
||||||
|
|
||||||
|
**调用例子 :** `/song/downlist`
|
||||||
|
|
||||||
|
### 会员本月下载歌曲记录
|
||||||
|
|
||||||
|
说明 : 调用此接口, 可获得当前账号会员本月下载歌曲记录
|
||||||
|
|
||||||
|
**可选参数 :**
|
||||||
|
|
||||||
|
`limit` : 返回数量 , 默认为 20
|
||||||
|
|
||||||
|
`offset` : 偏移数量,用于分页 ,如 :( 页数 -1)\*30, 其中 30 为 limit 的值 , 默认为 0
|
||||||
|
|
||||||
|
**接口地址 :** `/song/monthdownlist`
|
||||||
|
|
||||||
|
**调用例子 :** `/song/monthdownlist`
|
||||||
|
|
||||||
|
### 已购买单曲
|
||||||
|
|
||||||
|
说明 : 调用此接口, 可获得当前账号已购买单曲
|
||||||
|
|
||||||
|
**可选参数 :**
|
||||||
|
|
||||||
|
`limit` : 返回数量 , 默认为 20
|
||||||
|
|
||||||
|
`offset` : 偏移数量,用于分页 ,如 :( 页数 -1)\*30, 其中 30 为 limit 的值 , 默认为 0
|
||||||
|
|
||||||
|
**接口地址 :** `/song/singledownlist`
|
||||||
|
|
||||||
|
**调用例子 :** `/song/singledownlist`
|
||||||
|
|
||||||
## 离线访问此文档
|
## 离线访问此文档
|
||||||
|
|
||||||
此文档同时也是 Progressive Web Apps(PWA), 加入了 serviceWorker, 可离线访问
|
此文档同时也是 Progressive Web Apps(PWA), 加入了 serviceWorker, 可离线访问
|
||||||
|
@ -89,6 +89,16 @@ const createRequest = (method, uri, data = {}, options) => {
|
|||||||
encryptData = '',
|
encryptData = '',
|
||||||
crypto = options.crypto,
|
crypto = options.crypto,
|
||||||
csrfToken = cookie['__csrf'] || ''
|
csrfToken = cookie['__csrf'] || ''
|
||||||
|
|
||||||
|
if (crypto === '') {
|
||||||
|
// 加密方式为空,以配置文件的加密方式为准
|
||||||
|
if (APP_CONF.encrypt) {
|
||||||
|
crypto = 'eapi'
|
||||||
|
} else {
|
||||||
|
crypto = 'api'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 根据加密方式加密请求数据;目前任意uri都支持四种加密方式
|
// 根据加密方式加密请求数据;目前任意uri都支持四种加密方式
|
||||||
switch (crypto) {
|
switch (crypto) {
|
||||||
case 'weapi':
|
case 'weapi':
|
||||||
@ -112,7 +122,6 @@ const createRequest = (method, uri, data = {}, options) => {
|
|||||||
|
|
||||||
case 'eapi':
|
case 'eapi':
|
||||||
case 'api':
|
case 'api':
|
||||||
case '':
|
|
||||||
// 两种加密方式,都应生成客户端的cookie
|
// 两种加密方式,都应生成客户端的cookie
|
||||||
const cookie = options.cookie || {}
|
const cookie = options.cookie || {}
|
||||||
const header = {
|
const header = {
|
||||||
@ -160,13 +169,6 @@ const createRequest = (method, uri, data = {}, options) => {
|
|||||||
eapi()
|
eapi()
|
||||||
} else if (crypto === 'api') {
|
} else if (crypto === 'api') {
|
||||||
api()
|
api()
|
||||||
} else if (crypto === '') {
|
|
||||||
// 加密方式为空,以配置文件的加密方式为准
|
|
||||||
if (APP_CONF.encrypt) {
|
|
||||||
eapi()
|
|
||||||
} else {
|
|
||||||
api()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user