forked from Binaryify/NeteaseCloudMusicApi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaylist_tracks.js
56 lines (54 loc) · 1.23 KB
/
playlist_tracks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// 收藏单曲到歌单 从歌单删除歌曲
module.exports = async (query, request) => {
query.cookie.os = 'pc'
const tracks = query.tracks.split(',')
const data = {
op: query.op, // del,add
pid: query.pid, // 歌单id
trackIds: JSON.stringify(tracks), // 歌曲id
imme: 'true',
}
try {
const res = await request(
'POST',
`https://music.163.com/api/playlist/manipulate/tracks`,
data,
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
return {
status: 200,
body: {
...res,
},
}
} catch (error) {
if (error.body.code === 512) {
return request(
'POST',
`https://music.163.com/api/playlist/manipulate/tracks`,
{
op: query.op, // del,add
pid: query.pid, // 歌单id
trackIds: JSON.stringify([...tracks, ...tracks]),
imme: 'true',
},
{
crypto: 'weapi',
cookie: query.cookie,
proxy: query.proxy,
realIP: query.realIP,
},
)
} else if (error.body.code === 521) {
return {
status: 200,
body: error.body,
}
}
}
}