diff --git a/packages/api/module/artist_detail.js b/packages/api/module/artist_detail.js new file mode 100644 index 00000000..8bbb9d97 --- /dev/null +++ b/packages/api/module/artist_detail.js @@ -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, + }, + ) +} diff --git a/packages/api/module/artist_new_mv.js b/packages/api/module/artist_new_mv.js new file mode 100644 index 00000000..d08b1d58 --- /dev/null +++ b/packages/api/module/artist_new_mv.js @@ -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, + }, + ) +} diff --git a/packages/api/module/artist_new_song.js b/packages/api/module/artist_new_song.js new file mode 100644 index 00000000..53545999 --- /dev/null +++ b/packages/api/module/artist_new_song.js @@ -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, + }, + ) +} diff --git a/packages/api/module/comment_hug_list.js b/packages/api/module/comment_hug_list.js new file mode 100644 index 00000000..a8ef9596 --- /dev/null +++ b/packages/api/module/comment_hug_list.js @@ -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, + }, + ) +} diff --git a/packages/api/module/homepage_dragon_ball.js b/packages/api/module/homepage_dragon_ball.js index 362062a8..f441c5de 100644 --- a/packages/api/module/homepage_dragon_ball.js +++ b/packages/api/module/homepage_dragon_ball.js @@ -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', diff --git a/packages/api/module/hug_comment.js b/packages/api/module/hug_comment.js new file mode 100644 index 00000000..481b9a45 --- /dev/null +++ b/packages/api/module/hug_comment.js @@ -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, + }, + ) +} diff --git a/packages/api/module/msg_recentcontact.js b/packages/api/module/msg_recentcontact.js new file mode 100644 index 00000000..cb17c3a6 --- /dev/null +++ b/packages/api/module/msg_recentcontact.js @@ -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, + }, + ) +} diff --git a/packages/api/module/send_song.js b/packages/api/module/send_song.js new file mode 100644 index 00000000..b2d4b0d5 --- /dev/null +++ b/packages/api/module/send_song.js @@ -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, + }) +} diff --git a/packages/api/module/simi_artist.js b/packages/api/module/simi_artist.js index 555c1d9a..effef6b1 100644 --- a/packages/api/module/simi_artist.js +++ b/packages/api/module/simi_artist.js @@ -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, } diff --git a/packages/api/module/song_url.js b/packages/api/module/song_url.js index 2b3dd538..6e1c559a 100644 --- a/packages/api/module/song_url.js +++ b/packages/api/module/song_url.js @@ -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) @@ -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' diff --git a/packages/api/module/topic_sublist.js b/packages/api/module/topic_sublist.js new file mode 100644 index 00000000..153b2985 --- /dev/null +++ b/packages/api/module/topic_sublist.js @@ -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, + }) +} diff --git a/packages/api/module/user_event.js b/packages/api/module/user_event.js index c64e0cac..224626de 100644 --- a/packages/api/module/user_event.js +++ b/packages/api/module/user_event.js @@ -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, @@ -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, diff --git a/packages/api/package.json b/packages/api/package.json index 91350d0f..3bcc3804 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -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}", @@ -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" },