Skip to content

Commit b285705

Browse files
authored
Merge pull request #1 from Binaryify/master
首页-发现接口增加 cursor 参数,refresh默认设为false Binaryify#1217
2 parents e35a44e + 679be3d commit b285705

File tree

8 files changed

+123
-12
lines changed

8 files changed

+123
-12
lines changed

CHANGELOG.MD

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# 更新日志
2+
### 4.0.12 | 2021.5.1
3+
- 首页-发现接口增加 cursor 参数,refresh默认设为false [#1217](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/1217)
4+
5+
- 更新`song/detail` 接口
6+
27
### 4.0.11 | 2021.4.26
38
- 新增云盘歌曲信息匹配纠正接口 [#1212](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/1212)
49

docs/README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ $ set HOST=127.0.0.1 && node app.js
260260
```
261261

262262
## Vercel 部署
263-
v4.0.8 加入了 Vercel 配置文件,可以直接在 Vercel 下部署了,不需要自己的服务器
263+
v4.0.8 加入了 Vercel 配置文件,可以直接在 Vercel 下部署了,不需要自己的服务器(访问Vercel部署的接口,需要额外加一个realIP参数,如 `/song/url?id=191254&realIP=116.25.146.177`)
264264
### 操作方法
265265
1. fork 此项目
266266
2. 在 Vercel 官网点击 `New Project`
@@ -1502,7 +1502,9 @@ mp3url 不能直接用 , 可通过 `/song/url` 接口传入歌曲 id 获取具
15021502

15031503
**接口地址 :** `/homepage/block/page`
15041504

1505-
**可选参数 :** `refresh`: 是否刷新数据,默认为true
1505+
**可选参数 :** `refresh`: 是否刷新数据,默认为false
1506+
1507+
`cursor`: 上一条数据返回的cursor
15061508

15071509

15081510
### 首页-发现-圆形图标入口列表
@@ -1934,16 +1936,15 @@ mp3url 不能直接用 , 可通过 `/song/url` 接口传入歌曲 id 获取具
19341936

19351937
### 获取歌曲详情
19361938

1937-
说明 : 调用此接口 , 传入音乐 id(支持多个 id, 用 `,` 隔开), 可获得歌曲详情(注意:歌曲封面现在需要通过专辑内容接口获取)
1939+
说明 : 调用此接口 , 传入音乐 id(支持多个 id, 用 `,` 隔开), 可获得歌曲详情
19381940

19391941
**必选参数 :** `ids`: 音乐 id, 如 `ids=347230`
19401942

19411943
**接口地址 :** `/song/detail`
19421944

19431945
**调用例子 :** `/song/detail?ids=347230`,`/song/detail?ids=347230,347231`
19441946

1945-
返回数据如下图 :
1946-
![获取歌曲详情](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/songDetail.png)
1947+
19471948

19481949
### 获取专辑内容
19491950

@@ -1955,9 +1956,6 @@ mp3url 不能直接用 , 可通过 `/song/url` 接口传入歌曲 id 获取具
19551956

19561957
**调用例子 :** `/album?id=32311`
19571958

1958-
返回数据如下图 :
1959-
![获取专辑内容](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/%E4%B8%93%E8%BE%91.png)
1960-
19611959

19621960
### 专辑动态信息
19631961
说明 : 调用此接口 , 传入专辑 id, 可获得专辑动态信息,如是否收藏,收藏数,评论数,分享数

interface.d.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,10 @@ export function history_recommend_songs_detail(
643643
): Promise<Response>
644644

645645
export function homepage_block_page(
646-
params: { refresh?: 'true' | 'false' | boolean } & RequestBaseConfig,
646+
params: {
647+
refresh?: 'true' | 'false' | boolean
648+
cursor?: string
649+
} & RequestBaseConfig,
647650
): Promise<Response>
648651

649652
export function homepage_dragon_ball(

module/homepage_block_page.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
module.exports = (query, request) => {
55
query.cookie.os = 'ios'
66
query.cookie.appver = '8.1.20'
7-
const data = { refresh: query.refresh || true }
7+
const data = { refresh: query.refresh || false, cursor: query.cursor }
88
return request(
99
'POST',
1010
`https://music.163.com/api/homepage/block/page`,

module/song_detail.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = (query, request) => {
55
const data = {
66
c: '[' + query.ids.map((id) => '{"id":' + id + '}').join(',') + ']',
77
}
8-
return request('POST', `https://music.163.com/weapi/v3/song/detail`, data, {
8+
return request('POST', `https://music.163.com/api/v3/song/detail`, data, {
99
crypto: 'weapi',
1010
cookie: query.cookie,
1111
proxy: query.proxy,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "NeteaseCloudMusicApi",
3-
"version": "4.0.11",
3+
"version": "4.0.12",
44
"description": "网易云音乐 NodeJS 版 API",
55
"scripts": {
66
"start": "node app.js",

public/home.html

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<html lang="zh">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>home</title>
8+
</head>
9+
10+
<body>
11+
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js"></script>
12+
<script>
13+
const phone = '' // 这里填手机号
14+
const password = '' // 这里填密码
15+
const fileUpdateTime = {}
16+
let cookieToken = ''
17+
if (!phone || !password) {
18+
const msg = '请设置你的手机号码和密码'
19+
alert(msg)
20+
throw new Error(msg)
21+
}
22+
23+
async function login() {
24+
const res = await axios({
25+
url: `/login/cellphone?phone=${phone}&password=${encodeURIComponent(
26+
password,
27+
)}`,
28+
})
29+
cookieToken = res.data.cookie
30+
}
31+
async function main() {
32+
await login()
33+
const res = await axios({
34+
url: `/homepage/block/page`,
35+
data: {
36+
cookie: cookieToken,
37+
},
38+
method: 'post',
39+
})
40+
let cursor = ''
41+
console.log(res.data.data)
42+
if (res.data.data.hasMore) {
43+
cursor = res.data.data.cursor
44+
const res2 = await axios({
45+
url: `/homepage/block/page?time=${Date.now()}`,
46+
data: {
47+
cookie: cookieToken,
48+
cursor: cursor,
49+
},
50+
method: 'post',
51+
})
52+
}
53+
}
54+
main()
55+
</script>
56+
</body>
57+
58+
</html>

public/login.html

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE html>
2+
<html lang="zh">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>登录</title>
8+
</head>
9+
10+
<body>
11+
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js"></script>
12+
<script>
13+
const phone = '' // 这里填手机号
14+
const password = '' // 这里填密码
15+
const fileUpdateTime = {}
16+
if (!phone || !password) {
17+
const msg = '请设置你的手机号码和密码'
18+
alert(msg)
19+
throw new Error(msg)
20+
}
21+
22+
async function login() {
23+
const res = await axios({
24+
url: `/login/cellphone`,
25+
method: 'post',
26+
data: {
27+
phone: phone,
28+
password: password,
29+
},
30+
})
31+
return res.data.cookie
32+
}
33+
async function main() {
34+
const cookieToken = await login()
35+
const res = await axios({
36+
url: `/login/status`,
37+
method: 'post',
38+
data: {
39+
cookie: cookieToken,
40+
},
41+
})
42+
}
43+
main()
44+
</script>
45+
</body>
46+
47+
</html>

0 commit comments

Comments
 (0)