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 CHANGED
@@ -52,8 +52,10 @@ __export(index_exports, {
52
52
  getSearchHot: () => getSearchHot,
53
53
  getSearchSingerTab: () => getSearchSingerTab,
54
54
  getSearchSingerTabList: () => getSearchSingerTabList,
55
+ getSimilarSongRecommend: () => getSimilarSongRecommend,
55
56
  getSingerAlbum: () => getSingerAlbum,
56
57
  getSingerIndex: () => getSingerIndex,
58
+ getSingerSimilar: () => getSingerSimilar,
57
59
  getSingerSong: () => getSingerSong,
58
60
  getTicketInfo: () => getTicketInfo,
59
61
  getTodayRecommend: () => getTodayRecommend,
@@ -61,9 +63,12 @@ __export(index_exports, {
61
63
  getUrlV1: () => getUrlV1,
62
64
  getUrlV2: () => getUrlV2,
63
65
  getUserBadge: () => getUserBadge,
66
+ getUserCollect: () => getUserCollect,
64
67
  getUserHomePage: () => getUserHomePage,
68
+ getUserMyList: () => getUserMyList,
65
69
  getVersion: () => getVersion,
66
70
  loginNP: () => loginNP,
71
+ loginSim: () => loginSim,
67
72
  modules: () => modules_exports,
68
73
  queryUserInfo: () => queryUserInfo,
69
74
  searchAlbum: () => searchAlbum,
@@ -101,8 +106,10 @@ __export(modules_exports, {
101
106
  getSearchHot: () => getSearchHot,
102
107
  getSearchSingerTab: () => getSearchSingerTab,
103
108
  getSearchSingerTabList: () => getSearchSingerTabList,
109
+ getSimilarSongRecommend: () => getSimilarSongRecommend,
104
110
  getSingerAlbum: () => getSingerAlbum,
105
111
  getSingerIndex: () => getSingerIndex,
112
+ getSingerSimilar: () => getSingerSimilar,
106
113
  getSingerSong: () => getSingerSong,
107
114
  getTicketInfo: () => getTicketInfo,
108
115
  getTodayRecommend: () => getTodayRecommend,
@@ -110,9 +117,12 @@ __export(modules_exports, {
110
117
  getUrlV1: () => getUrlV1,
111
118
  getUrlV2: () => getUrlV2,
112
119
  getUserBadge: () => getUserBadge,
120
+ getUserCollect: () => getUserCollect,
113
121
  getUserHomePage: () => getUserHomePage,
122
+ getUserMyList: () => getUserMyList,
114
123
  getVersion: () => getVersion,
115
124
  loginNP: () => loginNP,
125
+ loginSim: () => loginSim,
116
126
  queryUserInfo: () => queryUserInfo,
117
127
  searchAlbum: () => searchAlbum,
118
128
  searchConcert: () => searchConcert,
@@ -520,7 +530,6 @@ var getMvInfo = async (mvIds, {
520
530
 
521
531
  // src/modules/mv_hls.ts
522
532
  var getMvHls = async (mvContentId, mvCopyrightId, url, size, format = "050012", needHttps = true) => {
523
- size = size.toString();
524
533
  url = encodeURIComponent(url);
525
534
  return await h5fetch(
526
535
  `https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/mvplayinfo.do?format=${format}&mvContentId=${mvContentId}&mvCopyrightId=${mvCopyrightId}&needHttps=${needHttps}&size=${size}&url=${url}`,
@@ -1174,6 +1183,145 @@ var getTodayRecommend = async (pacmtoken) => {
1174
1183
  return { data, pacmtoken: newPacmToken };
1175
1184
  };
1176
1185
 
1186
+ // src/modules/login_sim.ts
1187
+ var RSAKey2 = rsalib_default.RSAKey;
1188
+ function randomString2() {
1189
+ const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
1190
+ return random.toLowerCase();
1191
+ }
1192
+ var loginSim = {
1193
+ async simSend(phone) {
1194
+ var $;
1195
+ $ = {
1196
+ "isAsync": true,
1197
+ "sim": "1",
1198
+ "encMsisdn": "",
1199
+ "appType": "0",
1200
+ "relayState": "",
1201
+ "sourceID": "220029",
1202
+ "fingerPrint": "",
1203
+ "fingerPrintDetail": ""
1204
+ };
1205
+ const p = await getPublicKey();
1206
+ const { publicExponent, modulus } = p || {};
1207
+ if (!modulus || !publicExponent) {
1208
+ return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
1209
+ }
1210
+ const rsa2 = new RSAKey2();
1211
+ rsa2.setPublic(modulus, publicExponent);
1212
+ const encPhone = rsa2.encrypt(phone);
1213
+ const fakeFingerprint = randomString2();
1214
+ $.fingerPrint = fakeFingerprint;
1215
+ $.fingerPrintDetail = fakeFingerprint;
1216
+ $.encMsisdn = encPhone;
1217
+ const form = new URLSearchParams();
1218
+ for (const [key, value] of Object.entries($)) {
1219
+ form.append(key, String(value));
1220
+ }
1221
+ const send = await fetch(
1222
+ `https://passport.migu.cn/api/simauth/send`,
1223
+ {
1224
+ method: "POST",
1225
+ headers: {
1226
+ //'User-Agent': ua,
1227
+ "Host": "passport.migu.cn"
1228
+ },
1229
+ body: form
1230
+ }
1231
+ );
1232
+ if (!send.ok) return { error: "simauth f:net error" };
1233
+ const sendbody = await send.json();
1234
+ if (!sendbody && sendbody.status != "2000") {
1235
+ return { error: sendbody };
1236
+ }
1237
+ const sim_sessionid = sendbody.result.sim_sessionid || "";
1238
+ if (!sim_sessionid) return { error: "sim_sessionid e" };
1239
+ return { sim_sessionid };
1240
+ },
1241
+ async simQuery(sim_sessionid) {
1242
+ var $;
1243
+ $ = {
1244
+ "isAsync": true,
1245
+ "sim_sessionid": sim_sessionid,
1246
+ "sourceID": "220029"
1247
+ };
1248
+ const form = new URLSearchParams();
1249
+ for (const [key, value] of Object.entries($)) {
1250
+ form.append(key, String(value));
1251
+ }
1252
+ const query = await fetch(
1253
+ `https://passport.migu.cn/api/simauth/query`,
1254
+ {
1255
+ method: "POST",
1256
+ headers: { "Host": "passport.migu.cn" },
1257
+ body: form
1258
+ }
1259
+ );
1260
+ if (!query.ok) return { error: "simauth e" };
1261
+ const querybody = await query.json();
1262
+ if (querybody.status == "4071") {
1263
+ return { error: "waiting", body: querybody };
1264
+ } else if (querybody.status == "2000") {
1265
+ const token = querybody?.result?.token || "";
1266
+ const status = querybody?.status || "";
1267
+ return { token, status };
1268
+ } else {
1269
+ return { error: querybody.status, body: querybody };
1270
+ }
1271
+ }
1272
+ };
1273
+
1274
+ // src/modules/user_collect.ts
1275
+ var getUserCollect = async (pacmtoken, page = 1, size = 20) => {
1276
+ const res = await fetch(
1277
+ `https://app.c.nf.migu.cn/user/h5/user/collection/v1.0?pageNo=${page}&type=1&OPType=03&pageSize=${size}&resourceType=2021`,
1278
+ {
1279
+ method: "GET",
1280
+ headers: {
1281
+ "Cookie": `pacmtoken=${pacmtoken}`
1282
+ }
1283
+ }
1284
+ );
1285
+ const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
1286
+ const data = await res.json();
1287
+ return { data, pacmtoken: newPacmToken };
1288
+ };
1289
+
1290
+ // src/modules/user_myList.ts
1291
+ var getUserMyList = async (pacmtoken, queryType = 0, page = 1, size = 20) => {
1292
+ const res = await fetch(
1293
+ `https://app.c.nf.migu.cn/user/h5/my-music-list/v1.0?queryType=${queryType}&pageNo=${page}&pageSize=${size}`,
1294
+ {
1295
+ method: "GET",
1296
+ headers: {
1297
+ "Cookie": `pacmtoken=${pacmtoken}`
1298
+ }
1299
+ }
1300
+ );
1301
+ const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
1302
+ const data = await res.json();
1303
+ return { data, pacmtoken: newPacmToken };
1304
+ };
1305
+
1306
+ // src/modules/singer_similar.ts
1307
+ var getSingerSimilar = async (singerId) => {
1308
+ return await h5fetch(`https://app.c.nf.migu.cn/bmw/recommend-singer/similar/v1.0?singerId=${singerId}`);
1309
+ };
1310
+
1311
+ // src/modules/recommend_similarSong.ts
1312
+ var getSimilarSongRecommend = async (contentId = "") => {
1313
+ return await h5fetch(
1314
+ `https://app.c.nf.migu.cn/bmw/recommend-song/similar/v1.0?contentId=${contentId}`,
1315
+ {
1316
+ method: "GET",
1317
+ headers: {
1318
+ "deviceId": getDeviceId(),
1319
+ "recommendstatus": "1"
1320
+ }
1321
+ }
1322
+ );
1323
+ };
1324
+
1177
1325
  // src/index.ts
1178
1326
  function createClient() {
1179
1327
  return modules_exports;
@@ -1202,8 +1350,10 @@ function createClient() {
1202
1350
  getSearchHot,
1203
1351
  getSearchSingerTab,
1204
1352
  getSearchSingerTabList,
1353
+ getSimilarSongRecommend,
1205
1354
  getSingerAlbum,
1206
1355
  getSingerIndex,
1356
+ getSingerSimilar,
1207
1357
  getSingerSong,
1208
1358
  getTicketInfo,
1209
1359
  getTodayRecommend,
@@ -1211,9 +1361,12 @@ function createClient() {
1211
1361
  getUrlV1,
1212
1362
  getUrlV2,
1213
1363
  getUserBadge,
1364
+ getUserCollect,
1214
1365
  getUserHomePage,
1366
+ getUserMyList,
1215
1367
  getVersion,
1216
1368
  loginNP,
1369
+ loginSim,
1217
1370
  modules,
1218
1371
  queryUserInfo,
1219
1372
  searchAlbum,