Skip to content

Commit

Permalink
fix(hook): rework with latest PC clients
Browse files Browse the repository at this point in the history
Signed-off-by: Tianling Shen <i@cnsztl.eu.org>
  • Loading branch information
1715173329 committed Sep 24, 2022
1 parent 8e2531a commit 10103d5
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ hook.target.path = new Set([
'/api/song/enhance/player/url',
'/api/song/enhance/player/url/v1',
'/api/song/enhance/download/url',
'/api/song/enhance/download/url/v1',
'/api/song/enhance/privilege',
'/batch',
'/api/batch',
Expand Down Expand Up @@ -167,7 +168,10 @@ hook.request.before = (ctx) => {
ctx.netease = netease;
// console.log(netease.path, netease.param)

if (netease.path === '/api/song/enhance/download/url')
if (
netease.path === '/api/song/enhance/download/url' ||
netease.path === '/api/song/enhance/download/url/v1'
)
return pretendPlay(ctx);
}
})
Expand Down Expand Up @@ -338,6 +342,19 @@ hook.request.after = (ctx) => {
value['unplayableType'] = 'unknown';
value['unplayableUserIds'] = [];
}
if ('noCopyrightRcmd' in value)
value['noCopyrightRcmd'] = null;
if (
'payed' in value &&
value['flLevel'] === 'none' &&
value['plLevel'] === 'none' &&
value['dlLevel'] === 'none'
) {
value['flLevel'] = 'exhigh';
value['plLevel'] = 'exhigh';
value['dlLevel'] = 'exhigh';
value['payed'] = 1;
}
}
return value;
};
Expand Down Expand Up @@ -412,7 +429,21 @@ const pretendPlay = (ctx) => {
netease.param = { ids: `["${id}"]`, br };
query = crypto.linuxapi.encryptRequest(turn, netease.param);
} else {
const { id, br, e_r, header } = netease.param;
let { id, br, level, e_r, header } = netease.param;
if (!br && level) {
switch (level) {
case 'hires':
case 'loseless':
br = 999000;
break;
case 'exhigh':
br = 320000;
break;
case 'standard':
br = 128000;
break;
}
}
netease.param = { ids: `["${id}"]`, br, e_r, header };
query = crypto.eapi.encryptRequest(turn, netease.param);
}
Expand Down

0 comments on commit 10103d5

Please sign in to comment.