Skip to content

Commit

Permalink
添加电台api
Browse files Browse the repository at this point in the history
  • Loading branch information
MakcRe committed Aug 11, 2023
1 parent a31386f commit 1c152de
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
26 changes: 26 additions & 0 deletions module/fm_class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { appid, clientver, cryptoMd5, signParamsKey } = require('../util');
module.exports = (params, useAxios) => {
const dateTime = Date.now();
const dfid = params?.cookie?.dfid || params?.dfid || '-';
const userid = params?.cookie?.userid || params?.userid || 0;
const dataMap = {
kguid: userid,
clienttime: dateTime,
mid: cryptoMd5(dfid),
platform: 'android',
clientver,
uid: userid,
get_tracker: 1,
key: signParamsKey(dateTime),
appid,
};

return useAxios({
url: '/v1/class_fm_song',
encryptType: 'android',
method: 'POST',
data: dataMap,
cookie: params?.cookie || {},
headers: { 'x-router': 'fm.service.kugou.com' },
});
};
30 changes: 30 additions & 0 deletions module/fm_image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { appid, clientver, cryptoMd5, signParamsKey } = require('../util');
module.exports = (params, useAxios) => {
const dateTime = Date.now();
const dfid = params?.cookie?.dfid || params?.dfid || '-';
const userid = params?.cookie?.userid || params?.userid;
const token = params?.cookie?.token || params?.token;

const fmData = (params?.fmid || '').split(',').map((s) => ({ fields: 'imgUrl100,imgUrl50', fmid: s, fmtype: 2 }));

const dataMap = {
appid,
clienttime: dateTime,
clientver,
data: fmData,
dfid,
key: signParamsKey(dateTime),
mid: cryptoMd5(dfid),
};
if (userid) dataMap['userid'] = userid;
if (token) dataMap['token'] = token;

return useAxios({
url: '/v1/fm_info',
encryptType: 'android',
method: 'POST',
data: dataMap,
cookie: params?.cookie || {},
headers: { 'x-router': 'fm.service.kugou.com', 'Content-Type': 'application/json' },
});
};
26 changes: 26 additions & 0 deletions module/fm_recommend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { appid, clientver, cryptoMd5, signParamsKey } = require('../util');
module.exports = (params, useAxios) => {
const dateTime = Date.now();
const dfid = params?.cookie?.dfid || params?.dfid || '-';
const dataMap = {
appid,
clientver,
clienttime: dateTime,
mid: cryptoMd5(dfid),
key: signParamsKey(dateTime),
rcmdsongcount: 1,
level: 0,
area_code: 1,
get_tracker: 1,
uid: 0,
};

return useAxios({
url: '/v1/rcmd_list',
encryptType: 'android',
method: 'POST',
data: dataMap,
cookie: params?.cookie || {},
headers: { 'x-router': 'fm.service.kugou.com' },
});
};
42 changes: 42 additions & 0 deletions module/fm_songs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { appid, clientver, cryptoMd5, signParamsKey } = require('../util');
module.exports = (params, useAxios) => {
const dateTime = Date.now();
const dfid = params?.cookie?.dfid || params?.dfid || '-';
const userid = params?.cookie?.userid || params?.userid;

const fmData = (params?.fmid || '').split(',').map((s) => ({
fmid: s,
fmtype: params?.type || 2,
offset: params?.offset || -1,
size: params?.size || 20,
singername: s.singername || '',
}));

// fmType 生成
(params?.fmtype || '').split(',').forEach((s, l) => (fmData[l].fmtype = s || fmData[l].fmtype));

(params?.fmoffset || '').split(',').forEach((s, l) => (fmData[l].offset = s || fmData[l].offset));

(params?.fmsize || '').split(',').forEach((s, l) => (fmData[l].size = s || fmData[l].size));

const dataMap = {
appid,
area_code: 1,
clienttime: dateTime,
clientver,
data: fmData,
get_tracker: 1,
key: signParamsKey(dateTime),
mid: cryptoMd5(dfid),
uid: userid,
};

return useAxios({
url: '/v1/app_song_list_offset',
encryptType: 'android',
method: 'POST',
data: dataMap,
cookie: params?.cookie || {},
headers: { 'x-router': 'fm.service.kugou.com', 'Content-Type': 'application/json' },
});
};

0 comments on commit 1c152de

Please sign in to comment.