migu-api-enhanced 1.2.3 → 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/dist/index.cjs +154 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -3
- package/dist/index.d.ts +56 -3
- package/dist/index.js +149 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ declare const getMvInfo: (mvIds: string, { needAbsoluteUrl, }: {
|
|
|
71
71
|
needAbsoluteUrl?: boolean | undefined;
|
|
72
72
|
}) => Promise<any>;
|
|
73
73
|
|
|
74
|
-
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>;
|
|
75
75
|
|
|
76
76
|
declare const loginNP: {
|
|
77
77
|
authn(username: string, password: string): Promise<any>;
|
|
@@ -107,6 +107,54 @@ declare const getTodayRecommend: (pacmtoken: string) => Promise<{
|
|
|
107
107
|
pacmtoken: string;
|
|
108
108
|
}>;
|
|
109
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
|
+
|
|
110
158
|
/**
|
|
111
159
|
* modules 子目录统一入口
|
|
112
160
|
* 汇总导出所有 API 函数
|
|
@@ -133,8 +181,10 @@ declare const api_getSearchDefault: typeof getSearchDefault;
|
|
|
133
181
|
declare const api_getSearchHot: typeof getSearchHot;
|
|
134
182
|
declare const api_getSearchSingerTab: typeof getSearchSingerTab;
|
|
135
183
|
declare const api_getSearchSingerTabList: typeof getSearchSingerTabList;
|
|
184
|
+
declare const api_getSimilarSongRecommend: typeof getSimilarSongRecommend;
|
|
136
185
|
declare const api_getSingerAlbum: typeof getSingerAlbum;
|
|
137
186
|
declare const api_getSingerIndex: typeof getSingerIndex;
|
|
187
|
+
declare const api_getSingerSimilar: typeof getSingerSimilar;
|
|
138
188
|
declare const api_getSingerSong: typeof getSingerSong;
|
|
139
189
|
declare const api_getTicketInfo: typeof getTicketInfo;
|
|
140
190
|
declare const api_getTodayRecommend: typeof getTodayRecommend;
|
|
@@ -142,9 +192,12 @@ declare const api_getUrlH5V24: typeof getUrlH5V24;
|
|
|
142
192
|
declare const api_getUrlV1: typeof getUrlV1;
|
|
143
193
|
declare const api_getUrlV2: typeof getUrlV2;
|
|
144
194
|
declare const api_getUserBadge: typeof getUserBadge;
|
|
195
|
+
declare const api_getUserCollect: typeof getUserCollect;
|
|
145
196
|
declare const api_getUserHomePage: typeof getUserHomePage;
|
|
197
|
+
declare const api_getUserMyList: typeof getUserMyList;
|
|
146
198
|
declare const api_getVersion: typeof getVersion;
|
|
147
199
|
declare const api_loginNP: typeof loginNP;
|
|
200
|
+
declare const api_loginSim: typeof loginSim;
|
|
148
201
|
declare const api_queryUserInfo: typeof queryUserInfo;
|
|
149
202
|
declare const api_searchAlbum: typeof searchAlbum;
|
|
150
203
|
declare const api_searchConcert: typeof searchConcert;
|
|
@@ -155,7 +208,7 @@ declare const api_searchSuggest: typeof searchSuggest;
|
|
|
155
208
|
declare const api_searchTicket: typeof searchTicket;
|
|
156
209
|
declare const api_searchVideo: typeof searchVideo;
|
|
157
210
|
declare namespace api {
|
|
158
|
-
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_getSingerAlbum as getSingerAlbum, api_getSingerIndex as getSingerIndex, 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_getUserHomePage as getUserHomePage, api_getVersion as getVersion, api_loginNP as loginNP, 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 };
|
|
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 };
|
|
159
212
|
}
|
|
160
213
|
|
|
161
214
|
/**
|
|
@@ -172,4 +225,4 @@ declare function createClient(): typeof api;
|
|
|
172
225
|
/** 客户端类型 */
|
|
173
226
|
type MiguClient = ReturnType<typeof createClient>;
|
|
174
227
|
|
|
175
|
-
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, getSingerAlbum, getSingerIndex, getSingerSong, getTicketInfo, getTodayRecommend, getUrlH5V24, getUrlV1, getUrlV2, getUserBadge, getUserHomePage, getVersion, loginNP, api as modules, queryUserInfo, searchAlbum, searchConcert, searchRbt, searchSinger, searchSong, searchSuggest, searchTicket, searchVideo };
|
|
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
|
@@ -28,8 +28,10 @@ __export(modules_exports, {
|
|
|
28
28
|
getSearchHot: () => getSearchHot,
|
|
29
29
|
getSearchSingerTab: () => getSearchSingerTab,
|
|
30
30
|
getSearchSingerTabList: () => getSearchSingerTabList,
|
|
31
|
+
getSimilarSongRecommend: () => getSimilarSongRecommend,
|
|
31
32
|
getSingerAlbum: () => getSingerAlbum,
|
|
32
33
|
getSingerIndex: () => getSingerIndex,
|
|
34
|
+
getSingerSimilar: () => getSingerSimilar,
|
|
33
35
|
getSingerSong: () => getSingerSong,
|
|
34
36
|
getTicketInfo: () => getTicketInfo,
|
|
35
37
|
getTodayRecommend: () => getTodayRecommend,
|
|
@@ -37,9 +39,12 @@ __export(modules_exports, {
|
|
|
37
39
|
getUrlV1: () => getUrlV1,
|
|
38
40
|
getUrlV2: () => getUrlV2,
|
|
39
41
|
getUserBadge: () => getUserBadge,
|
|
42
|
+
getUserCollect: () => getUserCollect,
|
|
40
43
|
getUserHomePage: () => getUserHomePage,
|
|
44
|
+
getUserMyList: () => getUserMyList,
|
|
41
45
|
getVersion: () => getVersion,
|
|
42
46
|
loginNP: () => loginNP,
|
|
47
|
+
loginSim: () => loginSim,
|
|
43
48
|
queryUserInfo: () => queryUserInfo,
|
|
44
49
|
searchAlbum: () => searchAlbum,
|
|
45
50
|
searchConcert: () => searchConcert,
|
|
@@ -447,7 +452,6 @@ var getMvInfo = async (mvIds, {
|
|
|
447
452
|
|
|
448
453
|
// src/modules/mv_hls.ts
|
|
449
454
|
var getMvHls = async (mvContentId, mvCopyrightId, url, size, format = "050012", needHttps = true) => {
|
|
450
|
-
size = size.toString();
|
|
451
455
|
url = encodeURIComponent(url);
|
|
452
456
|
return await h5fetch(
|
|
453
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}`,
|
|
@@ -1101,6 +1105,145 @@ var getTodayRecommend = async (pacmtoken) => {
|
|
|
1101
1105
|
return { data, pacmtoken: newPacmToken };
|
|
1102
1106
|
};
|
|
1103
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
|
+
|
|
1104
1247
|
// src/index.ts
|
|
1105
1248
|
function createClient() {
|
|
1106
1249
|
return modules_exports;
|
|
@@ -1128,8 +1271,10 @@ export {
|
|
|
1128
1271
|
getSearchHot,
|
|
1129
1272
|
getSearchSingerTab,
|
|
1130
1273
|
getSearchSingerTabList,
|
|
1274
|
+
getSimilarSongRecommend,
|
|
1131
1275
|
getSingerAlbum,
|
|
1132
1276
|
getSingerIndex,
|
|
1277
|
+
getSingerSimilar,
|
|
1133
1278
|
getSingerSong,
|
|
1134
1279
|
getTicketInfo,
|
|
1135
1280
|
getTodayRecommend,
|
|
@@ -1137,9 +1282,12 @@ export {
|
|
|
1137
1282
|
getUrlV1,
|
|
1138
1283
|
getUrlV2,
|
|
1139
1284
|
getUserBadge,
|
|
1285
|
+
getUserCollect,
|
|
1140
1286
|
getUserHomePage,
|
|
1287
|
+
getUserMyList,
|
|
1141
1288
|
getVersion,
|
|
1142
1289
|
loginNP,
|
|
1290
|
+
loginSim,
|
|
1143
1291
|
modules_exports as modules,
|
|
1144
1292
|
queryUserInfo,
|
|
1145
1293
|
searchAlbum,
|