Skip to content

Commit

Permalink
1、添加 获取音乐URL 接口
Browse files Browse the repository at this point in the history
  • Loading branch information
MakcRe committed Jun 23, 2023
1 parent 3fc69a0 commit be0cc53
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ $ set HOST=127.0.0.1 && npm run dev
4. 每日推荐歌曲
5. 新碟上架
6. 专辑音乐列表
7. 专辑详情
7. 专辑详情
8. 获取音乐URL
2 changes: 2 additions & 0 deletions module/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const useModule = (params: UseModuleParams, useAxios: UseAxios) => {
res.cookie.push(`token=${getToken}`);
}
res.cookie.push(`userid=${res.body.data?.userid || 0}`)
res.cookie.push(`vip_type=${res.body.data?.vip_type || 0}`)
res.cookie.push(`vip_token=${res.body.data?.vip_token || ''}`)

resolve(res);
return;
Expand Down
2 changes: 2 additions & 0 deletions module/login_cellphone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export const useModule = (params: UseModuleParams, useAxios: UseAxios) => {
res.cookie.push(`token=${getToken}`);
}
res.cookie.push(`userid=${res.body.data?.userid || 0}`)
res.cookie.push(`vip_type=${res.body.data?.vip_type || 0}`)
res.cookie.push(`vip_token=${res.body.data?.vip_token || ''}`)

resolve(res);
return;
Expand Down
2 changes: 2 additions & 0 deletions module/login_openplat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export const useModule = (params: UseModuleParams, useAxios: UseAxios) => {
response.cookie.push(`token=${getToken}`);
}
response.cookie.push(`userid=${response.body.data?.userid || 0}`)
response.cookie.push(`vip_type=${response.body.data?.vip_type || 0}`)
response.cookie.push(`vip_token=${response.body.data?.vip_token || ''}`)
}
resolve(response);

Expand Down
4 changes: 2 additions & 2 deletions module/login_qr_check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const useModule = (params: UseModuleParams, useAxios: UseAxios) => {
cookie: params?.cookie || {},
}).then(resp => {
if (resp.body?.data?.status == 4) {
resp.cookie.push(`token=${resp.body?.data?.token}; PATH=/`);
resp.cookie.push(`userid=${resp.body?.data?.userid}; PATH=/`);
resp.cookie.push(`token=${resp.body?.data?.token}`);
resp.cookie.push(`userid=${resp.body?.data?.userid}`);
}
resolve(resp);
}).catch(e => reject(e));
Expand Down
2 changes: 2 additions & 0 deletions module/login_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const useModule = (params: UseModuleParams, useAxios: UseAxios) => {
res.cookie.push(`token=${getToken}`);
}
res.cookie.push(`userid=${res.body.data?.userid || 0}`)
res.cookie.push(`vip_type=${res.body.data?.vip_type || 0}`);
res.cookie.push(`vip_token=${res.body.data?.vip_token || ''}`);

resolve(res);
return;
Expand Down
28 changes: 28 additions & 0 deletions module/song_url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 新碟上架
import { mapToObject } from '../util/util';

// 华语: 1,欧美: 2,日本: 3,韩国: 4, 空为推荐
export const useModule = (params: UseModuleParams, useAxios: UseAxios) => {
const dataMap = new Map();
dataMap.set('hash', params?.hash || '');
dataMap.set('vipType', params?.cookie?.vip_type || params?.vipType || 0); // 该参数不影响url获取
dataMap.set('vipToken', params?.cookie?.vip_token || params?.vipToken || ''); // 该参数不影响url获取
dataMap.set('behavior', 'play');
dataMap.set('pid', 2);
dataMap.set('cmd', 26);
dataMap.set('version', 9541);
dataMap.set('pidversion', 3001);
dataMap.set('IsFreePart', params?.multitrack === '1' ? 3 : 1);

return useAxios({
url: '/v3/url',
method: 'GET',
params: mapToObject(dataMap),
encryptType: 'android',
headers: { 'x-router': 'tracker.kugou.com' },
encryptKey: true,
cookie: params?.cookie || {},
});
}

export default useModule;
4 changes: 3 additions & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ const consturctServer = async (moduleDefs?: ModuleDefinition[]): Promise<Express
}),
)
} else {
res.append('Set-Cookie', cookies)
res.append('Set-Cookie', cookies.map((cookie) => {
return cookie + '; PATH=/'
}),)
}
}
}
Expand Down

0 comments on commit be0cc53

Please sign in to comment.