diff --git a/README.MD b/README.MD index 6135715..2ae2a80 100644 --- a/README.MD +++ b/README.MD @@ -429,6 +429,9 @@ banner({ type: 0 }).then((res) => { 283. 云盘导入歌曲 284. 获取客户端歌曲下载链接 - 新版 285. 当前账号关注的用户/歌手 +286. 会员下载歌曲记录 +287. 会员本月下载歌曲记录 +288. 已购买单曲 ## 单元测试 diff --git a/module/api.js b/module/api.js index 6de8689..3cfa5dc 100644 --- a/module/api.js +++ b/module/api.js @@ -1,3 +1,4 @@ +const { cookieToJson } = require('../util/index') const createOption = require('../util/option.js') module.exports = (query, request) => { const method = query.method || 'POST' @@ -6,6 +7,10 @@ module.exports = (query, request) => { try { 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) { data = {} } diff --git a/module/song_downlist.js b/module/song_downlist.js new file mode 100644 index 0000000..9ac0f58 --- /dev/null +++ b/module/song_downlist.js @@ -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)) +} diff --git a/module/song_monthdownlist.js b/module/song_monthdownlist.js new file mode 100644 index 0000000..03eb8d5 --- /dev/null +++ b/module/song_monthdownlist.js @@ -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), + ) +} diff --git a/module/song_singledownlist.js b/module/song_singledownlist.js new file mode 100644 index 0000000..af8b08a --- /dev/null +++ b/module/song_singledownlist.js @@ -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), + ) +} diff --git a/public/api.html b/public/api.html index cd67e37..0912882 100644 --- a/public/api.html +++ b/public/api.html @@ -112,7 +112,7 @@ method: 'post', data: { uri: uri, - data: data, + data: JSON.parse(data), crypto: crypto, }, }); diff --git a/public/docs/home.md b/public/docs/home.md index ad2b56e..f2570bd 100644 --- a/public/docs/home.md +++ b/public/docs/home.md @@ -301,6 +301,9 @@ 283. 云盘导入歌曲 284. 获取客户端歌曲下载链接 - 新版 285. 当前账号关注的用户/歌手 +286. 会员下载歌曲记录 +287. 会员本月下载歌曲记录 +288. 已购买单曲 ## 安装 @@ -4714,6 +4717,48 @@ bitrate = Math.floor(br / 1000) **调用例子 :** `/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, 可离线访问 diff --git a/util/request.js b/util/request.js index 9bb6d06..ae4e820 100644 --- a/util/request.js +++ b/util/request.js @@ -89,6 +89,16 @@ const createRequest = (method, uri, data = {}, options) => { encryptData = '', crypto = options.crypto, csrfToken = cookie['__csrf'] || '' + + if (crypto === '') { + // 加密方式为空,以配置文件的加密方式为准 + if (APP_CONF.encrypt) { + crypto = 'eapi' + } else { + crypto = 'api' + } + } + // 根据加密方式加密请求数据;目前任意uri都支持四种加密方式 switch (crypto) { case 'weapi': @@ -112,7 +122,6 @@ const createRequest = (method, uri, data = {}, options) => { case 'eapi': case 'api': - case '': // 两种加密方式,都应生成客户端的cookie const cookie = options.cookie || {} const header = { @@ -160,13 +169,6 @@ const createRequest = (method, uri, data = {}, options) => { eapi() } else if (crypto === 'api') { api() - } else if (crypto === '') { - // 加密方式为空,以配置文件的加密方式为准 - if (APP_CONF.encrypt) { - eapi() - } else { - api() - } } break