Skip to content

Commit

Permalink
增加歌单(网友精选碟),新碟上架,热门歌手等接口,更新文档,版本更新到2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryify committed Apr 20, 2017
1 parent 832eade commit 3ccf8c4
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 更新日志
### 2.4.0 | 2017.4.20
增加歌单(网友精选碟),新碟上架,热门歌手等接口,更新文档

### 2.3.4 | 2017.4.20
增加歌曲详情接口,更新文档

Expand Down
4 changes: 4 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
[darknessomi/musicbox](https://github.com/darknessomi/musicbox)

## 版本新特性
### 2.4.0 | 2017.4.20
增加歌单(网友精选碟),新碟上架,热门歌手等接口,更新文档

### 2.3.4 | 2017.4.20
增加歌曲详情接口,更新文档

Expand Down Expand Up @@ -45,6 +48,7 @@
13. 把私人 FM 的歌曲移动至垃圾桶
14. 签到
15. 各排行榜
16. 歌曲详情

## 环境要求
需要 NodeJS 6.0+ 环境
Expand Down
11 changes: 10 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ app.use('/lyric', require('./router/lyric'))
// 获取专辑
app.use('/album', require('./router/album'))

// 获取歌单
// 歌单(网友精选碟) hot||new http://music.163.com/#/discover/playlist/
app.use('/top_playlist', require('./router/top_playlist'))

// 新碟上架 http://music.163.com/#/discover/album/
app.use('/new_albums', require('./router/new_albums'))

// 热门歌手 http://music.163.com/#/discover/artist/
app.use('/top_artists', require('./router/top_artists'))

// 获取用户歌单
app.use('/user/playlist', require('./router/userPlaylist'))

// 获取歌单内列表
Expand Down
72 changes: 67 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
跨站请求伪造 (CSRF), 伪造请求头,调用官方 API

## 版本新特性
Version 2.4.0
增加歌单(网友精选碟),新碟上架,热门歌手等接口,更新文档

Version 2.3.4
增加歌曲详情接口,更新文档

Expand All @@ -37,6 +40,9 @@ Version 2.2.0
14. 签到
15. 各排行榜
16. 歌曲详情
17. 歌单(网友精选碟)
18. 新碟上架
19. 热门歌手

## 安装
``` shell
Expand Down Expand Up @@ -159,7 +165,7 @@ $ set PORT=4000 && node app.js
1000: 歌单
1002: 用户

`offset` : 偏移数量,用于分页,如: 如:(评论页数-1)*30, 其中 30 为 limit 的值
`offset` : 偏移数量,用于分页,如: 如:(评论页数-1)*30, 其中 30 为 limit 的值,默认为0

**接口地址:**
`/search`
Expand Down Expand Up @@ -299,10 +305,10 @@ $ set PORT=4000 && node app.js
### 喜欢音乐
说明:调用此接口,传入音乐 id, 可喜欢该音乐
**必选参数:**
` id`: 歌曲 id
`id`: 歌曲 id

**可选参数:**
` like`: 布尔值,默认为 true 即喜欢,若传 false, 则取消喜欢
`like`: 布尔值,默认为 true 即喜欢,若传 false, 则取消喜欢

**接口地址:**
`/like`
Expand All @@ -324,7 +330,7 @@ $ set PORT=4000 && node app.js
说明:调用此接口,传入音乐 id, 可把该音乐从私人 FM中移除至垃圾桶

**必选参数:**
` id`: 歌曲 id
`id`: 歌曲 id

**接口地址:**
`/fm_trash`
Expand All @@ -336,11 +342,67 @@ $ set PORT=4000 && node app.js

![移除成功](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/fm_trash.png)

### 歌单(网友精选碟)
说明:调用此接口,可获取网友精选碟歌单

**可选参数:**
`limit`: 取出数量,默认为50

`offset`: 偏移数量,用于分页,如:(评论页数-1)*20, 其中 20 为 limit 的值,默认为0

`order`: 可选值为 'new' 和 'hot',分别对应最新和最热,默认为 'hot'

**接口地址:**
`/top_playlist`

**调用例子:**
`/top_playlist?limit=10&order=new`

返回数据如下图:

![精选碟](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/top_playlist.png)

### 新碟上架
说明:调用此接口,可获取新碟上架数据

**可选参数:**
`limit`: 取出数量,默认为50

`offset`: 偏移数量,用于分页,如:(评论页数-1)*50, 其中 50 为 limit 的值,默认为0

**接口地址:**
`/new_albums`

**调用例子:**
`/new_albums?offset=0&limit=30`

返回数据如下图:

![新碟上架](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/new_albums.png)

### 热门歌手
说明:调用此接口,可获取热门歌手数据

**可选参数:**
`limit`: 取出数量,默认为50

`offset`: 偏移数量,用于分页,如:(评论页数-1)*50, 其中 50 为 limit 的值,默认为0

**接口地址:**
`/top_artists`

**调用例子:**
`/top_artists?offset=0&limit=30`

返回数据如下图:

![热门歌手](https://raw.githubusercontent.com/Binaryify/NeteaseCloudMusicApi/master/static/top_artists.png)

### 排行榜
说明:调用此接口,传入数字 idx, 可获取不同排行榜

**必选参数:**
` idx`: 对象 key, 对应以下排行榜
`idx`: 对象 key, 对应以下排行榜

```
"0": 云音乐新歌榜,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "NeteaseCloudMusicApi",
"version": "2.3.4",
"version": "2.4.0",
"description": "网易云音乐 NodeJS 版 API",
"scripts": {
"start": "node app.js",
Expand Down
2 changes: 1 addition & 1 deletion router/fm_trash.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ router.get("/", (req, res) => {
const time = req.query.time || 25
createWebAPIRequest(
'music.163.com',
`http://music.163.com/api/radio/trash/add?alg=${alg}&songId=${songid}&time=${time}`,
`/api/radio/trash/add?alg=${alg}&songId=${songid}&time=${time}`,
'POST',
data,
cookie,
Expand Down
2 changes: 1 addition & 1 deletion router/like.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ router.get("/", (req, res) => {
const time = req.query.time || 25
createWebAPIRequest(
'music.163.com',
`http://music.163.com/api/radio/like?alg=${alg}&trackId=${trackId}&like=${like}&time=${time}`,
`/api/radio/like?alg=${alg}&trackId=${trackId}&like=${like}&time=${time}`,
'POST',
data,
cookie,
Expand Down
19 changes: 19 additions & 0 deletions router/new_albums.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const express = require("express")
const router = express()
const { createRequest } = require("../util/util")

router.get("/", (req, res) => {
const offset = req.query.offset || 0
const limit = req.query.limit || 50
createRequest(`/api/album/new?area=ALL&offset=${offset}&total=true&limit=${limit}`, 'GET', null)
.then(result => {
res.setHeader("Content-Type", "application/json")
res.send(result)
})
.catch(err => {
res.status(502).send('fetch error')
})
})


module.exports = router
4 changes: 2 additions & 2 deletions router/playlistDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ router.get("/", (req, res) => {
'POST',
data,
cookie,
music_req=> {
music_req => {
console.log(music_req)
detail = music_req
mergeRes()
},
err =>{
err => {
res.status(502).send('fetch error')
}
)
Expand Down
3 changes: 1 addition & 2 deletions router/songDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ const { createRequest } = require("../util/util")

router.get("/", (req, res) => {
const ids = req.query.ids
console.log(ids)
createRequest(`http://music.163.com/api/song/detail?ids=%5B${ids}%5D`, 'GET', null)
createRequest(`/api/song/detail?ids=%5B${ids}%5D`, 'GET', null)
.then(result => {
res.setHeader("Content-Type", "application/json")
res.send(result)
Expand Down
19 changes: 19 additions & 0 deletions router/top_artists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const express = require("express")
const router = express()
const { createRequest } = require("../util/util")

router.get("/", (req, res) => {
const offset = req.query.offset || 0
const limit = req.query.limit || 50
createRequest(`/api/artist/top?offset=${offset}&total=false&limit=${limit}`, 'GET', null)
.then(result => {
res.setHeader("Content-Type", "application/json")
res.send(result)
})
.catch(err => {
res.status(502).send('fetch error')
})
})


module.exports = router
26 changes: 26 additions & 0 deletions router/top_playlist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const express = require("express")
const router = express()
const { createWebAPIRequest } = require("../util/util")

router.get("/", (req, res) => {
const cookie = req.get('Cookie') ? req.get('Cookie') : ''
// order可为 'hot' 可为 'new'
const data = {
cat: req.query.cat || "全部",
order: req.query.order || "hot",
offset: req.query.offset || 0,
total: req.query.offset ? 'true' : 'false',
limit: req.query.limit || 50
}
createWebAPIRequest(
'music.163.com',
'/api/playlist/list',
'POST',
data,
cookie,
music_req => res.send(music_req),
err => res.status(502).send('fetch error')
)
})

module.exports = router

0 comments on commit 3ccf8c4

Please sign in to comment.