fix: 修复 issues #1019 的跟进问题 (#1068)

* issues #1019 的迫真修复

* 修复 issues #1019

* 修复 issues #1019

* 改回 pickedLyric() 逻辑

* 更进一步的避免取词卡死问题

* 更新网易云 api 到 4.2.0

* Update README.md

* Revert "Update README.md"

This reverts commit b862ef7d4dabd40c8fe57e4837fc6220806a1456.
master
是虹川飴 3 years ago committed by GitHub
parent 8341727882
commit 0d3df4a1e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,24 @@
// 歌手相关视频
module.exports = (query, request) => {
const data = {
artistId: query.id,
page: JSON.stringify({
size: query.size || 10,
cursor: query.cursor || 0,
}),
tab: 0,
order: query.order || 0,
}
return request(
'POST',
`https://music.163.com/weapi/mlog/artist/video`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -1,36 +0,0 @@
const { resourceTypeMap } = require('../util/config.json')
// 发送与删除评论
module.exports = (query, request) => {
query.cookie.os = 'pc'
query.t = {
1: 'add',
0: 'delete',
2: 'reply',
}[query.t]
query.type = resourceTypeMap[query.type]
const data = {
threadId: query.type + query.id,
}
if (query.type == 'A_EV_2_') {
data.threadId = query.threadId
}
if (query.t == 'add') data.content = query.content
else if (query.t == 'delete') data.commentId = query.commentId
else if (query.t == 'reply') {
data.commentId = query.commentId
data.content = query.content
}
return request(
'POST',
`https://music.163.com/weapi/resource/comments/${query.t}`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -1,22 +0,0 @@
// 专辑评论
module.exports = (query, request) => {
query.cookie.os = 'pc'
const data = {
rid: query.id,
limit: query.limit || 20,
offset: query.offset || 0,
beforeTime: query.before || 0,
}
return request(
'POST',
`https://music.163.com/weapi/v1/resource/comments/R_AL_3_${query.id}`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -1,22 +0,0 @@
// 电台评论
module.exports = (query, request) => {
query.cookie.os = 'pc'
const data = {
rid: query.id,
limit: query.limit || 20,
offset: query.offset || 0,
beforeTime: query.before || 0,
}
return request(
'POST',
`https://music.163.com/weapi/v1/resource/comments/A_DJ_1_${query.id}`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -1,21 +0,0 @@
const { resourceTypeMap } = require('../util/config.json')
module.exports = (query, request) => {
query.type = resourceTypeMap[query.type]
const data = {
parentCommentId: query.parentCommentId,
threadId: query.type + query.id,
time: query.time || -1,
limit: query.limit || 20,
}
return request(
'POST',
`https://music.163.com/api/resource/comment/floor/get`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -1,24 +0,0 @@
const { resourceTypeMap } = require('../util/config.json')
// 热门评论
module.exports = (query, request) => {
query.cookie.os = 'pc'
query.type = resourceTypeMap[query.type]
const data = {
rid: query.id,
limit: query.limit || 20,
offset: query.offset || 0,
beforeTime: query.before || 0,
}
return request(
'POST',
`https://music.163.com/weapi/v1/resource/hotcomments/${query.type}${query.id}`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -1,27 +0,0 @@
const { resourceTypeMap } = require('../util/config.json')
module.exports = (query, request) => {
query.cookie.os = 'ios'
query.cookie.appver = '8.1.20'
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,
},
)
}

@ -1,26 +0,0 @@
const { resourceTypeMap } = require('../util/config.json')
// 点赞与取消点赞评论
module.exports = (query, request) => {
query.cookie.os = 'pc'
query.t = query.t == 1 ? 'like' : 'unlike'
query.type = resourceTypeMap[query.type]
const data = {
threadId: query.type + query.id,
commentId: query.cid,
}
if (query.type == 'A_EV_2_') {
data.threadId = query.threadId
}
return request(
'POST',
`https://music.163.com/weapi/v1/comment/${query.t}`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -1,22 +0,0 @@
// 歌曲评论
module.exports = (query, request) => {
query.cookie.os = 'pc'
const data = {
rid: query.id,
limit: query.limit || 20,
offset: query.offset || 0,
beforeTime: query.before || 0,
}
return request(
'POST',
`https://music.163.com/api/v1/resource/comments/R_SO_4_${query.id}`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -1,22 +0,0 @@
// MV评论
module.exports = (query, request) => {
query.cookie.os = 'pc'
const data = {
rid: query.id,
limit: query.limit || 20,
offset: query.offset || 0,
beforeTime: query.before || 0,
}
return request(
'POST',
`https://music.163.com/weapi/v1/resource/comments/R_MV_5_${query.id}`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -1,31 +0,0 @@
const { resourceTypeMap } = require('../util/config.json')
// 评论
module.exports = (query, request) => {
query.cookie.os = 'pc'
query.type = resourceTypeMap[query.type]
const threadId = query.type + query.id
const pageSize = query.pageSize || 20
const pageNo = query.pageNo || 1
const data = {
threadId: threadId,
pageNo,
showInner: query.showInner || true,
pageSize,
cursor:
+query.sortType === 3 ? query.cursor || '0' : (pageNo - 1) * pageSize,
sortType: query.sortType || 1, //1:按推荐排序,2:按热度排序,3:按时间排序
}
return request(
'POST',
`https://music.163.com/api/v2/resource/comments`,
data,
{
crypto: 'eapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
url: '/api/v2/resource/comments',
},
)
}

@ -1,22 +0,0 @@
// 歌单评论
module.exports = (query, request) => {
query.cookie.os = 'pc'
const data = {
rid: query.id,
limit: query.limit || 20,
offset: query.offset || 0,
beforeTime: query.before || 0,
}
return request(
'POST',
`https://music.163.com/weapi/v1/resource/comments/A_PL_0_${query.id}`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -1,22 +0,0 @@
// 视频评论
module.exports = (query, request) => {
query.cookie.os = 'pc'
const data = {
rid: query.id,
limit: query.limit || 20,
offset: query.offset || 0,
beforeTime: query.before || 0,
}
return request(
'POST',
`https://music.163.com/weapi/v1/resource/comments/R_VI_62_${query.id}`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -5,7 +5,7 @@ module.exports = (query, request) => {
const data = {
name: query.name,
privacy: query.privacy, //0 为普通歌单10 为隐私歌单
type: query.type || 'NORMAL', // NORMAL|VIDEO
type: query.type || 'NORMAL', // NORMAL|VIDEO|SHARED
}
return request('POST', `https://music.163.com/api/playlist/create`, data, {
crypto: 'weapi',

@ -0,0 +1,47 @@
// 通过传过来的歌单id拿到所有歌曲数据
// 支持传递参数limit来限制获取歌曲的数据数量 例如: /playlist/track/all?id=7044354223&limit=10
module.exports = (query, request) => {
const data = {
id: query.id,
n: 100000,
s: query.s || 8,
}
//不放在data里面避免请求带上无用的数据
let limit = query.limit
let trackIds
let idsData = Object.create(null)
return request('POST', `https://music.163.com/api/v6/playlist/detail`, data, {
crypto: 'api',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
}).then((res) => {
const ids = []
let trackIds = res.body.playlist.trackIds
if (typeof limit === 'undefined') {
limit = trackIds.length
}
trackIds.forEach((item, index) => {
if (index < limit) {
ids.push(item.id)
}
})
idsData = {
c: '[' + ids.map((id) => '{"id":' + id + '}').join(',') + ']',
}
return request(
'POST',
`https://music.163.com/api/v3/song/detail`,
idsData,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
})
}

@ -1,14 +1,10 @@
// 获取动态评论
module.exports = (query, request) => {
const data = {
limit: query.limit || 20,
offset: query.offset || 0,
beforeTime: query.before || 0,
limit: query.limit || 100,
}
return request(
'POST',
`https://music.163.com/weapi/v1/resource/comments/${query.threadId}`,
`https://music.163.com/api/play-record/album/list`,
data,
{
crypto: 'weapi',

@ -1,14 +1,10 @@
// 分享歌曲到动态
module.exports = (query, request) => {
const data = {
type: query.type || 'song', // song,playlist,mv,djprogramdjradio
msg: query.msg || '',
id: query.id || '',
limit: query.limit || 100,
}
return request(
'POST',
`https://music.163.com/weapi/share/friends/resource`,
`https://music.163.com/api/play-record/djradio/list`,
data,
{
crypto: 'weapi',

@ -0,0 +1,16 @@
module.exports = (query, request) => {
const data = {
limit: query.limit || 100,
}
return request(
'POST',
`https://music.163.com/api/play-record/playlist/list`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -0,0 +1,16 @@
module.exports = (query, request) => {
const data = {
limit: query.limit || 100,
}
return request(
'POST',
`https://music.163.com/api/play-record/song/list`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -0,0 +1,16 @@
module.exports = (query, request) => {
const data = {
limit: query.limit || 100,
}
return request(
'POST',
`https://music.163.com/api/play-record/newvideo/list`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -0,0 +1,16 @@
module.exports = (query, request) => {
const data = {
limit: query.limit || 100,
}
return request(
'POST',
`https://music.163.com/api/play-record/voice/list`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
}

@ -0,0 +1,20 @@
// 获取客户端歌曲下载链接
module.exports = (query, request) => {
const data = {
id: query.id,
br: parseInt(query.br || 999000),
}
return request(
'POST',
`https://interface.music.163.com/eapi/song/enhance/download/url`,
data,
{
crypto: 'eapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
url: '/api/song/enhance/download/url',
},
)
}

@ -1,6 +1,6 @@
{
"name": "NeteaseCloudMusicApi",
"version": "4.0.8",
"version": "4.2.0",
"description": "网易云音乐 NodeJS 版 API",
"scripts": {
"start": "node app.js",

@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>home</title>
</head>
<body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js"></script>
<script>
const phone = '' // 这里填手机号
const password = '' // 这里填密码
const fileUpdateTime = {}
let cookieToken = ''
if (!phone || !password) {
const msg = '请设置你的手机号码和密码'
alert(msg)
throw new Error(msg)
}
async function login() {
const res = await axios({
url: `/login/cellphone?phone=${phone}&password=${encodeURIComponent(
password,
)}`,
})
cookieToken = res.data.cookie
}
async function main() {
await login()
const res = await axios({
url: `/homepage/block/page`,
data: {
cookie: cookieToken,
},
method: 'post',
})
let cursor = ''
console.log(res.data.data)
if (res.data.data.hasMore) {
cursor = res.data.data.cursor
const res2 = await axios({
url: `/homepage/block/page?time=${Date.now()}`,
data: {
cookie: cookieToken,
cursor: cursor,
},
method: 'post',
})
}
}
main()
</script>
</body>
</html>

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>登录</title>
</head>
<body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js"></script>
<script>
const phone = '' // 这里填手机号
const password = '' // 这里填密码
const fileUpdateTime = {}
if (!phone || !password) {
const msg = '请设置你的手机号码和密码'
alert(msg)
throw new Error(msg)
}
async function login() {
const res = await axios({
url: `/login/cellphone`,
method: 'post',
data: {
phone: phone,
password: password,
},
})
return res.data.cookie
}
async function main() {
const cookieToken = await login()
const res = await axios({
url: `/login/status`,
method: 'post',
data: {
cookie: cookieToken,
},
})
}
main()
</script>
</body>
</html>

@ -3,11 +3,14 @@ const axios = require('axios')
const host = global.host || 'http://localhost:3000'
console.log('注意: 测试登录需在 test/login.test.js 中填写账号密码!!!')
const phone = ''
const password = ''
const country_code = '1'
const phone = '3156678705'
const password = '1q2w3e4R'
describe('测试登录是否正常', () => {
it('手机登录 code 应该等于200', (done) => {
const qs = {
countrycode:
process.env.NCM_API_TEST_LOGIN_COUNTRY_CODE || country_code || '',
phone: process.env.NCM_API_TEST_LOGIN_PHONE || phone || '',
password: process.env.NCM_API_TEST_LOGIN_PASSWORD || password || '',
}

@ -117,7 +117,7 @@ const createRequest = (method, url, data, options) => {
headers: headers,
data: queryString.stringify(data),
httpAgent: new http.Agent({ keepAlive: true }),
httpsAgent: new https.Agent({ keepAlive: true, rejectUnauthorized: false }),
httpsAgent: new https.Agent({ keepAlive: true }),
}
if (options.crypto === 'eapi') settings.encoding = null
@ -127,7 +127,7 @@ const createRequest = (method, url, data, options) => {
settings.httpAgent = new PacProxyAgent(options.proxy)
settings.httpsAgent = new PacProxyAgent(options.proxy)
} else {
var purl = qs.parse(options.proxy)
const purl = qs.parse(options.proxy)
if (purl.hostname) {
const agent = tunnel.httpsOverHttp({
proxy: {
@ -142,6 +142,8 @@ const createRequest = (method, url, data, options) => {
console.error('代理配置无效,不使用代理')
}
}
} else {
settings.proxy = false
}
if (options.crypto === 'eapi') {
settings = {
@ -172,13 +174,19 @@ const createRequest = (method, url, data, options) => {
}
} catch (e) {
// console.log(e)
try {
answer.body = JSON.parse(body.toString())
} catch (err) {
// console.log(err)
// can't decrypt and can't parse directly
answer.body = body
}
answer.status = res.status
}
answer.status =
100 < answer.status && answer.status < 600 ? answer.status : 400
if (answer.status == 200) resolve(answer)
if (answer.status === 200) resolve(answer)
else reject(answer)
})
.catch((err) => {

@ -289,6 +289,9 @@ export default {
if (data.lrc !== undefined) {
let ifl = data.lrc.lyric.split('\n').filter(l => {
if (l.includes('作词')) {
if (l.includes('纯音乐,请欣赏') || l.includes('作词 : 无')) {
return false;
}
this.lyric = data.lrc.lyric;
return true + ifl;
}

Loading…
Cancel
Save