migu-api-enhanced 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -96
- package/dist/index.cjs +317 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -5
- package/dist/index.d.ts +90 -5
- package/dist/index.js +306 -31
- package/dist/index.js.map +1 -1
- package/package.json +62 -62
package/dist/index.d.ts
CHANGED
|
@@ -42,7 +42,14 @@ declare const getRankInfo: (rankId: string, page?: number) => Promise<any>;
|
|
|
42
42
|
|
|
43
43
|
declare const getRecommendPlaylist: () => Promise<any>;
|
|
44
44
|
|
|
45
|
-
declare const
|
|
45
|
+
declare const getSceneRecommend: (scene?: string, size?: number) => Promise<any>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 获取电台推荐
|
|
49
|
+
* @param type 1:上瘾电台 2:听见不同
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
declare const getRadioRecommend: (type?: number) => Promise<any>;
|
|
46
53
|
|
|
47
54
|
declare const getComment: (resourceId: string, resourceType?: number, size?: number, hotCommentStart?: number) => Promise<any>;
|
|
48
55
|
|
|
@@ -64,7 +71,7 @@ declare const getMvInfo: (mvIds: string, { needAbsoluteUrl, }: {
|
|
|
64
71
|
needAbsoluteUrl?: boolean | undefined;
|
|
65
72
|
}) => Promise<any>;
|
|
66
73
|
|
|
67
|
-
declare const getMvHls: (mvContentId: string, mvCopyrightId: string, url: string, size: number
|
|
74
|
+
declare const getMvHls: (mvContentId: string, mvCopyrightId: string, url: string, size: number, format?: string, needHttps?: boolean) => Promise<any>;
|
|
68
75
|
|
|
69
76
|
declare const loginNP: {
|
|
70
77
|
authn(username: string, password: string): Promise<any>;
|
|
@@ -80,6 +87,74 @@ declare const getPacmToken: (token?: string, type?: string, sourceId?: string, a
|
|
|
80
87
|
|
|
81
88
|
declare const getTicketInfo: (page?: number, pageCount?: number) => Promise<any>;
|
|
82
89
|
|
|
90
|
+
declare const getUserBadge: (pacmtoken: string) => Promise<{
|
|
91
|
+
data: any;
|
|
92
|
+
pacmtoken: string;
|
|
93
|
+
}>;
|
|
94
|
+
|
|
95
|
+
declare const queryUserInfo: (pacmtoken: string) => Promise<{
|
|
96
|
+
data: any;
|
|
97
|
+
pacmtoken: string;
|
|
98
|
+
}>;
|
|
99
|
+
|
|
100
|
+
declare const getUserHomePage: (pacmtoken: string) => Promise<{
|
|
101
|
+
data: any;
|
|
102
|
+
pacmtoken: string;
|
|
103
|
+
}>;
|
|
104
|
+
|
|
105
|
+
declare const getTodayRecommend: (pacmtoken: string) => Promise<{
|
|
106
|
+
data: any;
|
|
107
|
+
pacmtoken: string;
|
|
108
|
+
}>;
|
|
109
|
+
|
|
110
|
+
declare const loginSim: {
|
|
111
|
+
simSend(phone: string): Promise<{
|
|
112
|
+
error: any;
|
|
113
|
+
sim_sessionid?: undefined;
|
|
114
|
+
} | {
|
|
115
|
+
sim_sessionid: any;
|
|
116
|
+
error?: undefined;
|
|
117
|
+
}>;
|
|
118
|
+
simQuery(sim_sessionid: string): Promise<{
|
|
119
|
+
error: string;
|
|
120
|
+
token?: undefined;
|
|
121
|
+
status?: undefined;
|
|
122
|
+
body?: undefined;
|
|
123
|
+
} | {
|
|
124
|
+
token: any;
|
|
125
|
+
status: any;
|
|
126
|
+
error?: undefined;
|
|
127
|
+
body?: undefined;
|
|
128
|
+
} | {
|
|
129
|
+
error: any;
|
|
130
|
+
body: any;
|
|
131
|
+
token?: undefined;
|
|
132
|
+
status?: undefined;
|
|
133
|
+
}>;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
declare const getUserCollect: (pacmtoken: string, page?: number, size?: number) => Promise<{
|
|
137
|
+
data: any;
|
|
138
|
+
pacmtoken: string;
|
|
139
|
+
}>;
|
|
140
|
+
|
|
141
|
+
declare const getUserMyList: (pacmtoken: string, queryType?: number, page?: number, size?: number) => Promise<{
|
|
142
|
+
data: any;
|
|
143
|
+
pacmtoken: string;
|
|
144
|
+
}>;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 获取相似歌手
|
|
148
|
+
* @param singerId 歌手ID
|
|
149
|
+
*/
|
|
150
|
+
declare const getSingerSimilar: (singerId: string) => Promise<any>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 获取相似歌曲推荐
|
|
154
|
+
* @param contentId 歌曲ID
|
|
155
|
+
*/
|
|
156
|
+
declare const getSimilarSongRecommend: (contentId?: string) => Promise<any>;
|
|
157
|
+
|
|
83
158
|
/**
|
|
84
159
|
* modules 子目录统一入口
|
|
85
160
|
* 汇总导出所有 API 函数
|
|
@@ -96,24 +171,34 @@ declare const api_getOpNum: typeof getOpNum;
|
|
|
96
171
|
declare const api_getPacmToken: typeof getPacmToken;
|
|
97
172
|
declare const api_getPlaylistInfo: typeof getPlaylistInfo;
|
|
98
173
|
declare const api_getPlaylistSong: typeof getPlaylistSong;
|
|
174
|
+
declare const api_getRadioRecommend: typeof getRadioRecommend;
|
|
99
175
|
declare const api_getRankIndex: typeof getRankIndex;
|
|
100
176
|
declare const api_getRankInfo: typeof getRankInfo;
|
|
101
177
|
declare const api_getRecommendPlaylist: typeof getRecommendPlaylist;
|
|
102
|
-
declare const api_getRecommendSong: typeof getRecommendSong;
|
|
103
178
|
declare const api_getResourceInfo: typeof getResourceInfo;
|
|
179
|
+
declare const api_getSceneRecommend: typeof getSceneRecommend;
|
|
104
180
|
declare const api_getSearchDefault: typeof getSearchDefault;
|
|
105
181
|
declare const api_getSearchHot: typeof getSearchHot;
|
|
106
182
|
declare const api_getSearchSingerTab: typeof getSearchSingerTab;
|
|
107
183
|
declare const api_getSearchSingerTabList: typeof getSearchSingerTabList;
|
|
184
|
+
declare const api_getSimilarSongRecommend: typeof getSimilarSongRecommend;
|
|
108
185
|
declare const api_getSingerAlbum: typeof getSingerAlbum;
|
|
109
186
|
declare const api_getSingerIndex: typeof getSingerIndex;
|
|
187
|
+
declare const api_getSingerSimilar: typeof getSingerSimilar;
|
|
110
188
|
declare const api_getSingerSong: typeof getSingerSong;
|
|
111
189
|
declare const api_getTicketInfo: typeof getTicketInfo;
|
|
190
|
+
declare const api_getTodayRecommend: typeof getTodayRecommend;
|
|
112
191
|
declare const api_getUrlH5V24: typeof getUrlH5V24;
|
|
113
192
|
declare const api_getUrlV1: typeof getUrlV1;
|
|
114
193
|
declare const api_getUrlV2: typeof getUrlV2;
|
|
194
|
+
declare const api_getUserBadge: typeof getUserBadge;
|
|
195
|
+
declare const api_getUserCollect: typeof getUserCollect;
|
|
196
|
+
declare const api_getUserHomePage: typeof getUserHomePage;
|
|
197
|
+
declare const api_getUserMyList: typeof getUserMyList;
|
|
115
198
|
declare const api_getVersion: typeof getVersion;
|
|
116
199
|
declare const api_loginNP: typeof loginNP;
|
|
200
|
+
declare const api_loginSim: typeof loginSim;
|
|
201
|
+
declare const api_queryUserInfo: typeof queryUserInfo;
|
|
117
202
|
declare const api_searchAlbum: typeof searchAlbum;
|
|
118
203
|
declare const api_searchConcert: typeof searchConcert;
|
|
119
204
|
declare const api_searchRbt: typeof searchRbt;
|
|
@@ -123,7 +208,7 @@ declare const api_searchSuggest: typeof searchSuggest;
|
|
|
123
208
|
declare const api_searchTicket: typeof searchTicket;
|
|
124
209
|
declare const api_searchVideo: typeof searchVideo;
|
|
125
210
|
declare namespace api {
|
|
126
|
-
export { api_checkCanListen as checkCanListen, api_checkToken as checkToken, api_getAlbumInfo as getAlbumInfo, api_getAlbumSong as getAlbumSong, api_getComment as getComment, api_getMvHls as getMvHls, api_getMvInfo as getMvInfo, api_getOpNum as getOpNum, api_getPacmToken as getPacmToken, api_getPlaylistInfo as getPlaylistInfo, api_getPlaylistSong as getPlaylistSong, api_getRankIndex as getRankIndex, api_getRankInfo as getRankInfo, api_getRecommendPlaylist as getRecommendPlaylist,
|
|
211
|
+
export { api_checkCanListen as checkCanListen, api_checkToken as checkToken, api_getAlbumInfo as getAlbumInfo, api_getAlbumSong as getAlbumSong, api_getComment as getComment, api_getMvHls as getMvHls, api_getMvInfo as getMvInfo, api_getOpNum as getOpNum, api_getPacmToken as getPacmToken, api_getPlaylistInfo as getPlaylistInfo, api_getPlaylistSong as getPlaylistSong, api_getRadioRecommend as getRadioRecommend, api_getRankIndex as getRankIndex, api_getRankInfo as getRankInfo, api_getRecommendPlaylist as getRecommendPlaylist, api_getResourceInfo as getResourceInfo, api_getSceneRecommend as getSceneRecommend, api_getSearchDefault as getSearchDefault, api_getSearchHot as getSearchHot, api_getSearchSingerTab as getSearchSingerTab, api_getSearchSingerTabList as getSearchSingerTabList, api_getSimilarSongRecommend as getSimilarSongRecommend, api_getSingerAlbum as getSingerAlbum, api_getSingerIndex as getSingerIndex, api_getSingerSimilar as getSingerSimilar, api_getSingerSong as getSingerSong, api_getTicketInfo as getTicketInfo, api_getTodayRecommend as getTodayRecommend, api_getUrlH5V24 as getUrlH5V24, api_getUrlV1 as getUrlV1, api_getUrlV2 as getUrlV2, api_getUserBadge as getUserBadge, api_getUserCollect as getUserCollect, api_getUserHomePage as getUserHomePage, api_getUserMyList as getUserMyList, api_getVersion as getVersion, api_loginNP as loginNP, api_loginSim as loginSim, api_queryUserInfo as queryUserInfo, api_searchAlbum as searchAlbum, api_searchConcert as searchConcert, api_searchRbt as searchRbt, api_searchSinger as searchSinger, api_searchSong as searchSong, api_searchSuggest as searchSuggest, api_searchTicket as searchTicket, api_searchVideo as searchVideo };
|
|
127
212
|
}
|
|
128
213
|
|
|
129
214
|
/**
|
|
@@ -140,4 +225,4 @@ declare function createClient(): typeof api;
|
|
|
140
225
|
/** 客户端类型 */
|
|
141
226
|
type MiguClient = ReturnType<typeof createClient>;
|
|
142
227
|
|
|
143
|
-
export { type MiguClient, checkCanListen, checkToken, createClient, getAlbumInfo, getAlbumSong, getComment, getMvHls, getMvInfo, getOpNum, getPacmToken, getPlaylistInfo, getPlaylistSong, getRankIndex, getRankInfo, getRecommendPlaylist,
|
|
228
|
+
export { type MiguClient, checkCanListen, checkToken, createClient, getAlbumInfo, getAlbumSong, getComment, getMvHls, getMvInfo, getOpNum, getPacmToken, getPlaylistInfo, getPlaylistSong, getRadioRecommend, getRankIndex, getRankInfo, getRecommendPlaylist, getResourceInfo, getSceneRecommend, getSearchDefault, getSearchHot, getSearchSingerTab, getSearchSingerTabList, getSimilarSongRecommend, getSingerAlbum, getSingerIndex, getSingerSimilar, getSingerSong, getTicketInfo, getTodayRecommend, getUrlH5V24, getUrlV1, getUrlV2, getUserBadge, getUserCollect, getUserHomePage, getUserMyList, getVersion, loginNP, loginSim, api as modules, queryUserInfo, searchAlbum, searchConcert, searchRbt, searchSinger, searchSong, searchSuggest, searchTicket, searchVideo };
|
package/dist/index.js
CHANGED
|
@@ -18,24 +18,34 @@ __export(modules_exports, {
|
|
|
18
18
|
getPacmToken: () => getPacmToken,
|
|
19
19
|
getPlaylistInfo: () => getPlaylistInfo,
|
|
20
20
|
getPlaylistSong: () => getPlaylistSong,
|
|
21
|
+
getRadioRecommend: () => getRadioRecommend,
|
|
21
22
|
getRankIndex: () => getRankIndex,
|
|
22
23
|
getRankInfo: () => getRankInfo,
|
|
23
24
|
getRecommendPlaylist: () => getRecommendPlaylist,
|
|
24
|
-
getRecommendSong: () => getRecommendSong,
|
|
25
25
|
getResourceInfo: () => getResourceInfo,
|
|
26
|
+
getSceneRecommend: () => getSceneRecommend,
|
|
26
27
|
getSearchDefault: () => getSearchDefault,
|
|
27
28
|
getSearchHot: () => getSearchHot,
|
|
28
29
|
getSearchSingerTab: () => getSearchSingerTab,
|
|
29
30
|
getSearchSingerTabList: () => getSearchSingerTabList,
|
|
31
|
+
getSimilarSongRecommend: () => getSimilarSongRecommend,
|
|
30
32
|
getSingerAlbum: () => getSingerAlbum,
|
|
31
33
|
getSingerIndex: () => getSingerIndex,
|
|
34
|
+
getSingerSimilar: () => getSingerSimilar,
|
|
32
35
|
getSingerSong: () => getSingerSong,
|
|
33
36
|
getTicketInfo: () => getTicketInfo,
|
|
37
|
+
getTodayRecommend: () => getTodayRecommend,
|
|
34
38
|
getUrlH5V24: () => getUrlH5V24,
|
|
35
39
|
getUrlV1: () => getUrlV1,
|
|
36
40
|
getUrlV2: () => getUrlV2,
|
|
41
|
+
getUserBadge: () => getUserBadge,
|
|
42
|
+
getUserCollect: () => getUserCollect,
|
|
43
|
+
getUserHomePage: () => getUserHomePage,
|
|
44
|
+
getUserMyList: () => getUserMyList,
|
|
37
45
|
getVersion: () => getVersion,
|
|
38
46
|
loginNP: () => loginNP,
|
|
47
|
+
loginSim: () => loginSim,
|
|
48
|
+
queryUserInfo: () => queryUserInfo,
|
|
39
49
|
searchAlbum: () => searchAlbum,
|
|
40
50
|
searchConcert: () => searchConcert,
|
|
41
51
|
searchRbt: () => searchRbt,
|
|
@@ -178,9 +188,50 @@ var getRecommendPlaylist = async () => {
|
|
|
178
188
|
return await h5fetch(`http://app.c.nf.migu.cn/bmw/index-show/recommend-playlist/v3.0`);
|
|
179
189
|
};
|
|
180
190
|
|
|
191
|
+
// src/utils/deviceID.ts
|
|
192
|
+
function getDeviceId() {
|
|
193
|
+
const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
194
|
+
const a = `${random.substring(0, 8)}-${random.substring(8, 12)}-${random.substring(12, 16)}-${random.substring(16, 20)}-${random.substring(20)}`;
|
|
195
|
+
return a.toUpperCase();
|
|
196
|
+
}
|
|
197
|
+
|
|
181
198
|
// src/modules/recommend_song.ts
|
|
182
|
-
var
|
|
183
|
-
|
|
199
|
+
var getSceneRecommend = async (scene = "TODAY_RECOMMEND", size = 10) => {
|
|
200
|
+
let params = "";
|
|
201
|
+
if (scene === "PRIVATE_FM") {
|
|
202
|
+
params = "scene=PRIVATE_FM&algorithm=v1&action=1";
|
|
203
|
+
} else if (scene === "TODAY_RECOMMEND") {
|
|
204
|
+
params = `scene=TODAY_RECOMMEND&action=1&size=${size}`;
|
|
205
|
+
} else {
|
|
206
|
+
return { error: "scene\u53C2\u6570\u9519\u8BEF" };
|
|
207
|
+
}
|
|
208
|
+
return await h5fetch(
|
|
209
|
+
`https://app.c.nf.migu.cn/pc/resource-dataloader/recommend-song/v1.0?${params}`,
|
|
210
|
+
{
|
|
211
|
+
headers: {
|
|
212
|
+
"deviceId": getDeviceId()
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// src/modules/recommend_radio.ts
|
|
219
|
+
var getRadioRecommend = async (type = 1) => {
|
|
220
|
+
if (type !== 1 && type !== 2) {
|
|
221
|
+
return { error: "type must be 1 or 2" };
|
|
222
|
+
}
|
|
223
|
+
return await h5fetch(
|
|
224
|
+
`https://app.c.nf.migu.cn/pc/column/music-radio/recommend/song/v2.0?remain=0&actionId=1&type=${type}`,
|
|
225
|
+
{
|
|
226
|
+
method: "GET",
|
|
227
|
+
headers: {
|
|
228
|
+
"Referer": "https://music.migu.cn/",
|
|
229
|
+
"channel": "014X031",
|
|
230
|
+
"deviceId": getDeviceId(),
|
|
231
|
+
"recommendstatus": "1"
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
);
|
|
184
235
|
};
|
|
185
236
|
|
|
186
237
|
// src/modules/comment.ts
|
|
@@ -224,13 +275,6 @@ var getUrlV1 = async (contentId, copyrightId, resourceType = "2") => {
|
|
|
224
275
|
);
|
|
225
276
|
};
|
|
226
277
|
|
|
227
|
-
// src/utils/deviceID.ts
|
|
228
|
-
function getDeviceId() {
|
|
229
|
-
const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
230
|
-
const a = `${random.substring(0, 8)}-${random.substring(8, 12)}-${random.substring(12, 16)}-${random.substring(16, 20)}-${random.substring(20)}`;
|
|
231
|
-
return a.toUpperCase();
|
|
232
|
-
}
|
|
233
|
-
|
|
234
278
|
// src/modules/url_v2.ts
|
|
235
279
|
var getUrlV2 = async (contentId, copyrightId, resourceType = "2", pacmtoken = "") => {
|
|
236
280
|
const deviceId = getDeviceId();
|
|
@@ -408,7 +452,6 @@ var getMvInfo = async (mvIds, {
|
|
|
408
452
|
|
|
409
453
|
// src/modules/mv_hls.ts
|
|
410
454
|
var getMvHls = async (mvContentId, mvCopyrightId, url, size, format = "050012", needHttps = true) => {
|
|
411
|
-
size = size.toString();
|
|
412
455
|
url = encodeURIComponent(url);
|
|
413
456
|
return await h5fetch(
|
|
414
457
|
`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/mvplayinfo.do?format=${format}&mvContentId=${mvContentId}&mvCopyrightId=${mvCopyrightId}&needHttps=${needHttps}&size=${size}&url=${url}`,
|
|
@@ -937,6 +980,32 @@ var checkToken = async (token = "") => {
|
|
|
937
980
|
);
|
|
938
981
|
};
|
|
939
982
|
|
|
983
|
+
// src/utils/setCookie.ts
|
|
984
|
+
var parseSetCookies = (headers) => {
|
|
985
|
+
if (typeof headers.getSetCookie === "function") {
|
|
986
|
+
return headers.getSetCookie() || [];
|
|
987
|
+
}
|
|
988
|
+
const setCookieHeader = headers.get("set-cookie");
|
|
989
|
+
if (!setCookieHeader) {
|
|
990
|
+
return [];
|
|
991
|
+
}
|
|
992
|
+
return setCookieHeader.split(",").map((c) => c.trim());
|
|
993
|
+
};
|
|
994
|
+
var getCookieValue = (cookies, key) => {
|
|
995
|
+
for (const item of cookies) {
|
|
996
|
+
const prefix = `${key}=`;
|
|
997
|
+
if (item.includes(prefix)) {
|
|
998
|
+
const mainPart = item.split(";")[0];
|
|
999
|
+
return mainPart.split("=")[1] || "";
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return "";
|
|
1003
|
+
};
|
|
1004
|
+
var getSetCookieValue = (headers, key) => {
|
|
1005
|
+
const cookies = parseSetCookies(headers);
|
|
1006
|
+
return getCookieValue(cookies, key);
|
|
1007
|
+
};
|
|
1008
|
+
|
|
940
1009
|
// src/modules/passport_pacmToken.ts
|
|
941
1010
|
var getPacmToken = async (token = "", type = "2", sourceId = "220029", activityId = "MUSIC-WWW") => {
|
|
942
1011
|
const res = await fetch(
|
|
@@ -944,7 +1013,6 @@ var getPacmToken = async (token = "", type = "2", sourceId = "220029", activityI
|
|
|
944
1013
|
{
|
|
945
1014
|
headers: {
|
|
946
1015
|
"Cookie": "idmpauth=true@passport.migu.cn",
|
|
947
|
-
//?
|
|
948
1016
|
"Origin": "https://music.migu.cn",
|
|
949
1017
|
"Pragma": "no-cache",
|
|
950
1018
|
"Referer": "https://music.migu.cn/"
|
|
@@ -952,24 +1020,8 @@ var getPacmToken = async (token = "", type = "2", sourceId = "220029", activityI
|
|
|
952
1020
|
method: "GET"
|
|
953
1021
|
}
|
|
954
1022
|
);
|
|
955
|
-
const
|
|
956
|
-
|
|
957
|
-
if (typeof headers.getSetCookie === "function") {
|
|
958
|
-
cookie = headers.getSetCookie() || [];
|
|
959
|
-
} else {
|
|
960
|
-
const setCookieHeader = headers.get("set-cookie");
|
|
961
|
-
if (setCookieHeader) {
|
|
962
|
-
cookie = setCookieHeader.split(",").map((c) => c.trim());
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
let pacmToken = "";
|
|
966
|
-
cookie.forEach((item) => {
|
|
967
|
-
if (item.includes("pacmtoken=")) {
|
|
968
|
-
pacmToken = item.split(";")[0];
|
|
969
|
-
pacmToken = pacmToken.split("=")[1];
|
|
970
|
-
return;
|
|
971
|
-
}
|
|
972
|
-
});
|
|
1023
|
+
const cookie = parseSetCookies(res.headers);
|
|
1024
|
+
const pacmToken = getCookieValue(cookie, "pacmtoken");
|
|
973
1025
|
const body = await res.json();
|
|
974
1026
|
return { pacmToken, cookie, body };
|
|
975
1027
|
};
|
|
@@ -979,6 +1031,219 @@ var getTicketInfo = async (page = 1, pageCount = 20) => {
|
|
|
979
1031
|
return await h5fetch(`https://app.c.nf.migu.cn/MIGUM3.0/v1.0/ticket/home/ticket?pageNum=${page}&pageCount=${pageCount}`);
|
|
980
1032
|
};
|
|
981
1033
|
|
|
1034
|
+
// src/modules/user_badge.ts
|
|
1035
|
+
var getUserBadge = async (pacmtoken) => {
|
|
1036
|
+
const res = await fetch(
|
|
1037
|
+
`https://app.c.nf.migu.cn/pc/open/api/member/icon/v1.0`,
|
|
1038
|
+
{
|
|
1039
|
+
method: "GET",
|
|
1040
|
+
headers: {
|
|
1041
|
+
"Cookie": `pacmtoken=${pacmtoken}`,
|
|
1042
|
+
"Referer": "https://music.migu.cn/",
|
|
1043
|
+
"channel": "014X031",
|
|
1044
|
+
"timestamp": Date.now().toString()
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
);
|
|
1048
|
+
const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
|
|
1049
|
+
const data = await res.json();
|
|
1050
|
+
return { data, pacmtoken: newPacmToken };
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
// src/modules/user_queryInfo.ts
|
|
1054
|
+
var queryUserInfo = async (pacmtoken) => {
|
|
1055
|
+
const res = await fetch(
|
|
1056
|
+
`https://app.c.nf.migu.cn/pc/user/h5/queryUserInfo/v1.0`,
|
|
1057
|
+
{
|
|
1058
|
+
method: "GET",
|
|
1059
|
+
headers: {
|
|
1060
|
+
"Cookie": `pacmtoken=${pacmtoken}`,
|
|
1061
|
+
"channel": "014X031",
|
|
1062
|
+
"Referer": `https://music.migu.cn/`
|
|
1063
|
+
//可不用
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
);
|
|
1067
|
+
const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
|
|
1068
|
+
const data = await res.json();
|
|
1069
|
+
return { data, pacmtoken: newPacmToken };
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1072
|
+
// src/modules/user_homePage.ts
|
|
1073
|
+
var getUserHomePage = async (pacmtoken) => {
|
|
1074
|
+
const res = await fetch(
|
|
1075
|
+
`https://app.c.nf.migu.cn/pc/user/home-page/v2.0`,
|
|
1076
|
+
{
|
|
1077
|
+
method: "GET",
|
|
1078
|
+
headers: {
|
|
1079
|
+
"Cookie": `pacmtoken=${pacmtoken}`
|
|
1080
|
+
//"channel": "014X031",
|
|
1081
|
+
//"Referer": `https://music.migu.cn/`
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
);
|
|
1085
|
+
const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
|
|
1086
|
+
const data = await res.json();
|
|
1087
|
+
return { data, pacmtoken: newPacmToken };
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
// src/modules/user_recom_today.ts
|
|
1091
|
+
var getTodayRecommend = async (pacmtoken) => {
|
|
1092
|
+
const res = await fetch(
|
|
1093
|
+
`https://app.c.nf.migu.cn/pc/v1.0/template/todayRecommendList/release?actionId=1&index=1&templateVersion=5`,
|
|
1094
|
+
{
|
|
1095
|
+
method: "GET",
|
|
1096
|
+
headers: {
|
|
1097
|
+
"Cookie": `pacmtoken=${pacmtoken}`
|
|
1098
|
+
//"channel": "014X031",
|
|
1099
|
+
//"Referer": `https://music.migu.cn/`
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
);
|
|
1103
|
+
const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
|
|
1104
|
+
const data = await res.json();
|
|
1105
|
+
return { data, pacmtoken: newPacmToken };
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1108
|
+
// src/modules/login_sim.ts
|
|
1109
|
+
var RSAKey2 = rsalib_default.RSAKey;
|
|
1110
|
+
function randomString2() {
|
|
1111
|
+
const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
1112
|
+
return random.toLowerCase();
|
|
1113
|
+
}
|
|
1114
|
+
var loginSim = {
|
|
1115
|
+
async simSend(phone) {
|
|
1116
|
+
var $;
|
|
1117
|
+
$ = {
|
|
1118
|
+
"isAsync": true,
|
|
1119
|
+
"sim": "1",
|
|
1120
|
+
"encMsisdn": "",
|
|
1121
|
+
"appType": "0",
|
|
1122
|
+
"relayState": "",
|
|
1123
|
+
"sourceID": "220029",
|
|
1124
|
+
"fingerPrint": "",
|
|
1125
|
+
"fingerPrintDetail": ""
|
|
1126
|
+
};
|
|
1127
|
+
const p = await getPublicKey();
|
|
1128
|
+
const { publicExponent, modulus } = p || {};
|
|
1129
|
+
if (!modulus || !publicExponent) {
|
|
1130
|
+
return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
|
|
1131
|
+
}
|
|
1132
|
+
const rsa2 = new RSAKey2();
|
|
1133
|
+
rsa2.setPublic(modulus, publicExponent);
|
|
1134
|
+
const encPhone = rsa2.encrypt(phone);
|
|
1135
|
+
const fakeFingerprint = randomString2();
|
|
1136
|
+
$.fingerPrint = fakeFingerprint;
|
|
1137
|
+
$.fingerPrintDetail = fakeFingerprint;
|
|
1138
|
+
$.encMsisdn = encPhone;
|
|
1139
|
+
const form = new URLSearchParams();
|
|
1140
|
+
for (const [key, value] of Object.entries($)) {
|
|
1141
|
+
form.append(key, String(value));
|
|
1142
|
+
}
|
|
1143
|
+
const send = await fetch(
|
|
1144
|
+
`https://passport.migu.cn/api/simauth/send`,
|
|
1145
|
+
{
|
|
1146
|
+
method: "POST",
|
|
1147
|
+
headers: {
|
|
1148
|
+
//'User-Agent': ua,
|
|
1149
|
+
"Host": "passport.migu.cn"
|
|
1150
|
+
},
|
|
1151
|
+
body: form
|
|
1152
|
+
}
|
|
1153
|
+
);
|
|
1154
|
+
if (!send.ok) return { error: "simauth f:net error" };
|
|
1155
|
+
const sendbody = await send.json();
|
|
1156
|
+
if (!sendbody && sendbody.status != "2000") {
|
|
1157
|
+
return { error: sendbody };
|
|
1158
|
+
}
|
|
1159
|
+
const sim_sessionid = sendbody.result.sim_sessionid || "";
|
|
1160
|
+
if (!sim_sessionid) return { error: "sim_sessionid e" };
|
|
1161
|
+
return { sim_sessionid };
|
|
1162
|
+
},
|
|
1163
|
+
async simQuery(sim_sessionid) {
|
|
1164
|
+
var $;
|
|
1165
|
+
$ = {
|
|
1166
|
+
"isAsync": true,
|
|
1167
|
+
"sim_sessionid": sim_sessionid,
|
|
1168
|
+
"sourceID": "220029"
|
|
1169
|
+
};
|
|
1170
|
+
const form = new URLSearchParams();
|
|
1171
|
+
for (const [key, value] of Object.entries($)) {
|
|
1172
|
+
form.append(key, String(value));
|
|
1173
|
+
}
|
|
1174
|
+
const query = await fetch(
|
|
1175
|
+
`https://passport.migu.cn/api/simauth/query`,
|
|
1176
|
+
{
|
|
1177
|
+
method: "POST",
|
|
1178
|
+
headers: { "Host": "passport.migu.cn" },
|
|
1179
|
+
body: form
|
|
1180
|
+
}
|
|
1181
|
+
);
|
|
1182
|
+
if (!query.ok) return { error: "simauth e" };
|
|
1183
|
+
const querybody = await query.json();
|
|
1184
|
+
if (querybody.status == "4071") {
|
|
1185
|
+
return { error: "waiting", body: querybody };
|
|
1186
|
+
} else if (querybody.status == "2000") {
|
|
1187
|
+
const token = querybody?.result?.token || "";
|
|
1188
|
+
const status = querybody?.status || "";
|
|
1189
|
+
return { token, status };
|
|
1190
|
+
} else {
|
|
1191
|
+
return { error: querybody.status, body: querybody };
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
// src/modules/user_collect.ts
|
|
1197
|
+
var getUserCollect = async (pacmtoken, page = 1, size = 20) => {
|
|
1198
|
+
const res = await fetch(
|
|
1199
|
+
`https://app.c.nf.migu.cn/user/h5/user/collection/v1.0?pageNo=${page}&type=1&OPType=03&pageSize=${size}&resourceType=2021`,
|
|
1200
|
+
{
|
|
1201
|
+
method: "GET",
|
|
1202
|
+
headers: {
|
|
1203
|
+
"Cookie": `pacmtoken=${pacmtoken}`
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
);
|
|
1207
|
+
const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
|
|
1208
|
+
const data = await res.json();
|
|
1209
|
+
return { data, pacmtoken: newPacmToken };
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1212
|
+
// src/modules/user_myList.ts
|
|
1213
|
+
var getUserMyList = async (pacmtoken, queryType = 0, page = 1, size = 20) => {
|
|
1214
|
+
const res = await fetch(
|
|
1215
|
+
`https://app.c.nf.migu.cn/user/h5/my-music-list/v1.0?queryType=${queryType}&pageNo=${page}&pageSize=${size}`,
|
|
1216
|
+
{
|
|
1217
|
+
method: "GET",
|
|
1218
|
+
headers: {
|
|
1219
|
+
"Cookie": `pacmtoken=${pacmtoken}`
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
);
|
|
1223
|
+
const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
|
|
1224
|
+
const data = await res.json();
|
|
1225
|
+
return { data, pacmtoken: newPacmToken };
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
// src/modules/singer_similar.ts
|
|
1229
|
+
var getSingerSimilar = async (singerId) => {
|
|
1230
|
+
return await h5fetch(`https://app.c.nf.migu.cn/bmw/recommend-singer/similar/v1.0?singerId=${singerId}`);
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
// src/modules/recommend_similarSong.ts
|
|
1234
|
+
var getSimilarSongRecommend = async (contentId = "") => {
|
|
1235
|
+
return await h5fetch(
|
|
1236
|
+
`https://app.c.nf.migu.cn/bmw/recommend-song/similar/v1.0?contentId=${contentId}`,
|
|
1237
|
+
{
|
|
1238
|
+
method: "GET",
|
|
1239
|
+
headers: {
|
|
1240
|
+
"deviceId": getDeviceId(),
|
|
1241
|
+
"recommendstatus": "1"
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
);
|
|
1245
|
+
};
|
|
1246
|
+
|
|
982
1247
|
// src/index.ts
|
|
983
1248
|
function createClient() {
|
|
984
1249
|
return modules_exports;
|
|
@@ -996,25 +1261,35 @@ export {
|
|
|
996
1261
|
getPacmToken,
|
|
997
1262
|
getPlaylistInfo,
|
|
998
1263
|
getPlaylistSong,
|
|
1264
|
+
getRadioRecommend,
|
|
999
1265
|
getRankIndex,
|
|
1000
1266
|
getRankInfo,
|
|
1001
1267
|
getRecommendPlaylist,
|
|
1002
|
-
getRecommendSong,
|
|
1003
1268
|
getResourceInfo,
|
|
1269
|
+
getSceneRecommend,
|
|
1004
1270
|
getSearchDefault,
|
|
1005
1271
|
getSearchHot,
|
|
1006
1272
|
getSearchSingerTab,
|
|
1007
1273
|
getSearchSingerTabList,
|
|
1274
|
+
getSimilarSongRecommend,
|
|
1008
1275
|
getSingerAlbum,
|
|
1009
1276
|
getSingerIndex,
|
|
1277
|
+
getSingerSimilar,
|
|
1010
1278
|
getSingerSong,
|
|
1011
1279
|
getTicketInfo,
|
|
1280
|
+
getTodayRecommend,
|
|
1012
1281
|
getUrlH5V24,
|
|
1013
1282
|
getUrlV1,
|
|
1014
1283
|
getUrlV2,
|
|
1284
|
+
getUserBadge,
|
|
1285
|
+
getUserCollect,
|
|
1286
|
+
getUserHomePage,
|
|
1287
|
+
getUserMyList,
|
|
1015
1288
|
getVersion,
|
|
1016
1289
|
loginNP,
|
|
1290
|
+
loginSim,
|
|
1017
1291
|
modules_exports as modules,
|
|
1292
|
+
queryUserInfo,
|
|
1018
1293
|
searchAlbum,
|
|
1019
1294
|
searchConcert,
|
|
1020
1295
|
searchRbt,
|