Skip to content

Commit

Permalink
chore: synchronize part of the api code
Browse files Browse the repository at this point in the history
  • Loading branch information
hq001 committed Dec 8, 2020
1 parent d26e2ec commit 79e4e95
Show file tree
Hide file tree
Showing 13 changed files with 174 additions and 3 deletions.
15 changes: 15 additions & 0 deletions packages/api/module/artist_detail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = (query, request) => {
return request(
'POST',
`https://music.163.com/api/artist/head/info/get`,
{
id: query.id,
},
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}
19 changes: 19 additions & 0 deletions packages/api/module/artist_new_mv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = (query, request) => {
query.cookie.os = 'ios'
query.cookie.appver = '7.3.40'
const data = {
limit: query.limit || 20,
startTimestamp: query.before || Date.now(),
}
return request(
'POST',
`https://music.163.com/api/sub/artist/new/works/mv/list`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}
19 changes: 19 additions & 0 deletions packages/api/module/artist_new_song.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = (query, request) => {
query.cookie.os = 'ios'
query.cookie.appver = '7.3.40'
const data = {
limit: query.limit || 20,
startTimestamp: query.before || Date.now(),
}
return request(
'POST',
`https://music.163.com/api/sub/artist/new/works/song/list`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}
27 changes: 27 additions & 0 deletions packages/api/module/comment_hug_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { resourceTypeMap } = require('../util/config.json')
module.exports = (query, request) => {
query.cookie.os = 'ios'
query.cookie.appver = '7.3.27'
query.type = resourceTypeMap[query.type || 0]
const threadId = query.type + query.sid
const data = {
targetUserId: query.uid,
commentId: query.cid,
cursor: query.cursor || '-1',
threadId: threadId,
pageNo: query.page || 1,
idCursor: query.idCursor || -1,
pageSize: query.pageSize || 100,
}
return request(
'POST',
`https://music.163.com/api/v2/resource/comments/hug/list`,
data,
{
crypto: 'api',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}
6 changes: 6 additions & 0 deletions packages/api/module/homepage_dragon_ball.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
// 这个接口为移动端接口,首页-发现页(每日推荐、歌单、排行榜 那些入口)
// 数据结构可以参考 https://github.com/hcanyz/flutter-netease-music-api/blob/master/lib/src/api/uncategorized/bean.dart#L290 HomeDragonBallWrap
// !需要登录或者匿名登录,非登录返回 []
const config = require('../util/config.json')
module.exports = (query, request) => {
if (typeof query.cookie === 'string') {
query.cookie = cookieToJson(query.cookie)
}
if (!('MUSIC_U' in query.cookie))
query.cookie.MUSIC_A = config.anonymous_token
const data = {}
return request(
'POST',
Expand Down
23 changes: 23 additions & 0 deletions packages/api/module/hug_comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { resourceTypeMap } = require('../util/config.json')
module.exports = (query, request) => {
query.cookie.os = 'ios'
query.cookie.appver = '7.3.27'
query.type = resourceTypeMap[query.type || 0]
const threadId = query.type + query.sid
const data = {
targetUserId: query.uid,
commentId: query.cid,
threadId: threadId,
}
return request(
'POST',
`https://music.163.com/api/v2/resource/comments/hug/listener`,
data,
{
crypto: 'api',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}
16 changes: 16 additions & 0 deletions packages/api/module/msg_recentcontact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 最近联系

module.exports = (query, request) => {
const data = {}
return request(
'POST',
`https://music.163.com/api/msg/recentcontact/get`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}
18 changes: 18 additions & 0 deletions packages/api/module/send_song.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 私信歌曲

module.exports = (query, request) => {
query.cookie.os = 'ios'
query.cookie.appver = '7.3.27'
const data = {
id: query.id,
msg: query.msg || '',
type: 'song',
userIds: '[' + query.user_ids + ']',
}
return request('POST', `https://music.163.com/api/msg/private/send`, data, {
crypto: 'api',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
})
}
7 changes: 6 additions & 1 deletion packages/api/module/simi_artist.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// 相似歌手

const config = require('../util/config.json')
module.exports = (query, request) => {
if (typeof query.cookie === 'string') {
query.cookie = cookieToJson(query.cookie)
}
if (!('MUSIC_U' in query.cookie))
query.cookie.MUSIC_A = config.anonymous_token
const data = {
artistid: query.id,
}
Expand Down
4 changes: 4 additions & 0 deletions packages/api/module/song_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 从 packages/unblock 中解析网易云音乐ID的播放链接,突破灰色歌曲限制
const match = require('@radishes/unblock')
const crypto = require('crypto')
const { cookieToJson } = require('../util/index')

const find = (id) => {
return match(id)
Expand All @@ -15,6 +16,9 @@ const find = (id) => {
}

module.exports = (query, request) => {
if (typeof query.cookie === 'string') {
query.cookie = cookieToJson(query.cookie)
}
if (!('MUSIC_U' in query.cookie))
query.cookie._ntes_nuid = crypto.randomBytes(16).toString('hex')
query.cookie.os = 'pc'
Expand Down
15 changes: 15 additions & 0 deletions packages/api/module/topic_sublist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 收藏的专栏

module.exports = (query, request) => {
const data = {
limit: query.limit || 50,
offset: query.offset || 0,
total: true,
}
return request('POST', `https://music.163.com/api/topic/sublist`, data, {
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
})
}
6 changes: 4 additions & 2 deletions packages/api/module/user_event.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// 用户动态

module.exports = (query, request) => {
query.cookie.os = 'ios'
query.cookie.appver = '7.3.27'
const data = {
getcounts: true,
time: query.lasttime || -1,
Expand All @@ -9,10 +11,10 @@ module.exports = (query, request) => {
}
return request(
'POST',
`https://music.163.com/weapi/event/get/${query.uid}`,
`https://music.163.com/api/event/get/${query.uid}`,
data,
{
crypto: 'weapi',
crypto: 'api',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
Expand Down
2 changes: 2 additions & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "3.45.2",
"description": "网易云音乐 NodeJS 版 API",
"scripts": {
"dev": "nodemon app.js",
"start": "node app.js",
"test": "mocha -r intelli-espower-loader -t 20000 app.test.js --exit",
"lint": "eslint **/*.{js,ts}",
Expand Down Expand Up @@ -45,6 +46,7 @@
"axios": "^0.20.0",
"express": "^4.17.1",
"express-fileupload": "^1.1.9",
"nodemon": "^2.0.6",
"pac-proxy-agent": "^4.0.0",
"tunnel": "^0.0.6"
},
Expand Down

0 comments on commit 79e4e95

Please sign in to comment.