mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 06:07:48 +00:00
feat: integrate api in electron app
This commit is contained in:
parent
bd29570e31
commit
74bf714c28
240 changed files with 21003 additions and 112 deletions
51
napi/module/playlist_tracks.js
Normal file
51
napi/module/playlist_tracks.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// 收藏单曲到歌单 从歌单删除歌曲
|
||||
|
||||
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,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue