migu-api-enhanced 1.2.6 → 2.2.1

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
@@ -30,6 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ MiguUtils: () => utils_exports,
34
+ RSAKey: () => RSAKey,
35
+ URLParams: () => URLParams,
33
36
  YDRZ: () => YDRZ,
34
37
  checkCanListen: () => checkCanListen,
35
38
  checkToken: () => checkToken,
@@ -37,13 +40,20 @@ __export(index_exports, {
37
40
  getAlbumInfo: () => getAlbumInfo,
38
41
  getAlbumSong: () => getAlbumSong,
39
42
  getComment: () => getComment,
43
+ getDeviceId: () => getDeviceId,
44
+ getMVRecommend: () => getMVRecommend,
40
45
  getMvHls: () => getMvHls,
41
46
  getMvInfo: () => getMvInfo,
47
+ getNinanByDate: () => getNinanByDate,
48
+ getNinanSong: () => getNinanSong,
42
49
  getOpNum: () => getOpNum,
43
50
  getPacmToken: () => getPacmToken,
44
51
  getPlaylistInfo: () => getPlaylistInfo,
45
52
  getPlaylistSong: () => getPlaylistSong,
53
+ getPlaylistSquare: () => getPlaylistSquare,
54
+ getPublicKey: () => getPublicKey,
46
55
  getRadioRecommend: () => getRadioRecommend,
56
+ getRadioRecommendAll: () => getRadioRecommendAll,
47
57
  getRankIndex: () => getRankIndex,
48
58
  getRankInfo: () => getRankInfo,
49
59
  getRecommendPlaylist: () => getRecommendPlaylist,
@@ -70,17 +80,21 @@ __export(index_exports, {
70
80
  getVersion: () => getVersion,
71
81
  loginNP: () => loginNP,
72
82
  loginOneClick: () => loginOneClick,
83
+ loginPhone: () => loginPhone,
73
84
  loginSim: () => loginSim,
74
85
  modules: () => modules_exports,
75
86
  queryUserInfo: () => queryUserInfo,
87
+ randomUA: () => randomUA,
76
88
  searchAlbum: () => searchAlbum,
77
89
  searchConcert: () => searchConcert,
90
+ searchLrc: () => searchLrc,
78
91
  searchRbt: () => searchRbt,
79
92
  searchSinger: () => searchSinger,
80
93
  searchSong: () => searchSong,
81
94
  searchSuggest: () => searchSuggest,
82
95
  searchTicket: () => searchTicket,
83
- searchVideo: () => searchVideo
96
+ searchVideo: () => searchVideo,
97
+ ua: () => ua
84
98
  });
85
99
  module.exports = __toCommonJS(index_exports);
86
100
 
@@ -93,13 +107,18 @@ __export(modules_exports, {
93
107
  getAlbumInfo: () => getAlbumInfo,
94
108
  getAlbumSong: () => getAlbumSong,
95
109
  getComment: () => getComment,
110
+ getMVRecommend: () => getMVRecommend,
96
111
  getMvHls: () => getMvHls,
97
112
  getMvInfo: () => getMvInfo,
113
+ getNinanByDate: () => getNinanByDate,
114
+ getNinanSong: () => getNinanSong,
98
115
  getOpNum: () => getOpNum,
99
116
  getPacmToken: () => getPacmToken,
100
117
  getPlaylistInfo: () => getPlaylistInfo,
101
118
  getPlaylistSong: () => getPlaylistSong,
119
+ getPlaylistSquare: () => getPlaylistSquare,
102
120
  getRadioRecommend: () => getRadioRecommend,
121
+ getRadioRecommendAll: () => getRadioRecommendAll,
103
122
  getRankIndex: () => getRankIndex,
104
123
  getRankInfo: () => getRankInfo,
105
124
  getRecommendPlaylist: () => getRecommendPlaylist,
@@ -126,10 +145,12 @@ __export(modules_exports, {
126
145
  getVersion: () => getVersion,
127
146
  loginNP: () => loginNP,
128
147
  loginOneClick: () => loginOneClick,
148
+ loginPhone: () => loginPhone,
129
149
  loginSim: () => loginSim,
130
150
  queryUserInfo: () => queryUserInfo,
131
151
  searchAlbum: () => searchAlbum,
132
152
  searchConcert: () => searchConcert,
153
+ searchLrc: () => searchLrc,
133
154
  searchRbt: () => searchRbt,
134
155
  searchSinger: () => searchSinger,
135
156
  searchSong: () => searchSong,
@@ -365,7 +386,7 @@ var getUrlV1 = async (contentId, copyrightId, resourceType = "2") => {
365
386
  };
366
387
 
367
388
  // src/modules/url_v2.ts
368
- var getUrlV2 = async (contentId, copyrightId, resourceType = "2", pacmtoken = "") => {
389
+ var getUrlV2 = async (contentId, copyrightId, toneFlag = "PQ", resourceType = "2", pacmtoken = "") => {
369
390
  const deviceId = getDeviceId();
370
391
  const timestamp = Date.now();
371
392
  const headers = {
@@ -392,7 +413,7 @@ var getUrlV2 = async (contentId, copyrightId, resourceType = "2", pacmtoken = ""
392
413
  "location-info": ""
393
414
  };
394
415
  const res = await fetch(
395
- `https://app.c.nf.migu.cn/strategy/pc/listen/v2.0?contentId=${contentId}&copyrightId=${copyrightId}&scene=&netType=01&resourceType=${resourceType}&toneFlag=PQ`,
416
+ `https://app.c.nf.migu.cn/strategy/pc/listen/v2.0?contentId=${contentId}&copyrightId=${copyrightId}&scene=&netType=01&resourceType=${resourceType}&toneFlag=${toneFlag}`,
396
417
  {
397
418
  headers
398
419
  }
@@ -437,7 +458,7 @@ async function decryptData(blob) {
437
458
  }
438
459
 
439
460
  // src/modules/url_h5v2.4.ts
440
- var getUrlH5V24 = async (contentId, copyrightId, resourceType = "2") => {
461
+ var getUrlH5V24 = async (contentId, copyrightId, toneFlag = "PQ", resourceType = "2") => {
441
462
  const headers = {
442
463
  "birth": "h5page",
443
464
  "channel": "014X031",
@@ -446,7 +467,7 @@ var getUrlH5V24 = async (contentId, copyrightId, resourceType = "2") => {
446
467
  "location-info": ""
447
468
  };
448
469
  const res = await fetch(
449
- `https://c.musicapp.migu.cn/strategy/listen-url/h5/v2.4?contentId=${contentId}&copyrightId=${copyrightId}&resourceType=${resourceType}&netType=01&toneFlag=PQ&scene=&lowerQualityContentId=${contentId}`,
470
+ `https://c.musicapp.migu.cn/strategy/listen-url/h5/v2.4?contentId=${contentId}&copyrightId=${copyrightId}&resourceType=${resourceType}&netType=01&toneFlag=${toneFlag}&scene=&lowerQualityContentId=${contentId}`,
450
471
  {
451
472
  headers
452
473
  }
@@ -503,13 +524,13 @@ var decryptData2 = async (blob) => {
503
524
  };
504
525
 
505
526
  // src/modules/version.ts
506
- var getVersion = async (channel = "0146921", version = "8.4.0", ua = "Android_migu") => {
527
+ var getVersion = async (channel = "0146921", version = "8.4.0", ua2 = "Android_migu") => {
507
528
  return await h5fetch(
508
529
  `http://app.c.nf.migu.cn/MIGUM2.0/resource/client/version/v1.0`,
509
530
  {
510
531
  headers: {
511
532
  "channel": channel,
512
- "ua": ua,
533
+ "ua": ua2,
513
534
  "version": version
514
535
  }
515
536
  }
@@ -517,8 +538,8 @@ var getVersion = async (channel = "0146921", version = "8.4.0", ua = "Android_mi
517
538
  };
518
539
 
519
540
  // src/modules/mv_info.ts
520
- var getMvInfo = async (mvIds) => {
521
- return h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvIds}&resourceType=D&needSimple=01`);
541
+ var getMvInfo = async (mvContentId) => {
542
+ return await h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvContentId}&resourceType=D&needSimple=01`);
522
543
  };
523
544
 
524
545
  // src/modules/mv_hls.ts
@@ -580,7 +601,6 @@ var RSAKey = class {
580
601
  }
581
602
  }
582
603
  };
583
- var rsalib_default = { RSAKey };
584
604
 
585
605
  // src/utils/publicKey.ts
586
606
  var getPublicKey = async () => {
@@ -607,7 +627,6 @@ function URLParams($) {
607
627
  }
608
628
 
609
629
  // src/modules/login_np.ts
610
- var RSAKey2 = rsalib_default.RSAKey;
611
630
  function randomString() {
612
631
  const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
613
632
  return random.toLowerCase();
@@ -637,7 +656,7 @@ var loginNP = {
637
656
  if (!modulus || !publicExponent) {
638
657
  return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
639
658
  }
640
- var rsa = new RSAKey2();
659
+ var rsa = new RSAKey();
641
660
  rsa.setPublic(modulus, publicExponent);
642
661
  const rsa_pwd = rsa.encrypt(password);
643
662
  const rsa_username = rsa.encrypt(username);
@@ -652,7 +671,10 @@ var loginNP = {
652
671
  {
653
672
  method: "POST",
654
673
  headers: {
655
- "Host": "passport.migu.cn"
674
+ "Host": "passport.migu.cn",
675
+ "Content-Type": "application/x-www-form-urlencoded",
676
+ "Referer": "https://passport.migu.cn/login",
677
+ "Origin": "https://passport.migu.cn"
656
678
  },
657
679
  body: form
658
680
  }
@@ -801,7 +823,6 @@ var getTodayRecommend = async (pacmtoken) => {
801
823
  };
802
824
 
803
825
  // src/modules/login_sim.ts
804
- var RSAKey3 = rsalib_default.RSAKey;
805
826
  function randomString2() {
806
827
  const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
807
828
  return random.toLowerCase();
@@ -824,7 +845,7 @@ var loginSim = {
824
845
  if (!modulus || !publicExponent) {
825
846
  return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
826
847
  }
827
- const rsa = new RSAKey3();
848
+ const rsa = new RSAKey();
828
849
  rsa.setPublic(modulus, publicExponent);
829
850
  const encPhone = rsa.encrypt(phone);
830
851
  const fakeFingerprint = randomString2();
@@ -837,8 +858,10 @@ var loginSim = {
837
858
  {
838
859
  method: "POST",
839
860
  headers: {
840
- //'User-Agent': ua,
841
- "Host": "passport.migu.cn"
861
+ "Host": "passport.migu.cn",
862
+ "Content-Type": "application/x-www-form-urlencoded",
863
+ "Referer": "https://passport.migu.cn/login",
864
+ "Origin": "https://passport.migu.cn"
842
865
  },
843
866
  body: form
844
867
  }
@@ -867,7 +890,12 @@ var loginSim = {
867
890
  `https://passport.migu.cn/api/simauth/query`,
868
891
  {
869
892
  method: "POST",
870
- headers: { "Host": "passport.migu.cn" },
893
+ headers: {
894
+ "Host": "passport.migu.cn",
895
+ "Content-Type": "application/x-www-form-urlencoded",
896
+ "Referer": "https://passport.migu.cn/login",
897
+ "Origin": "https://passport.migu.cn"
898
+ },
871
899
  body: form
872
900
  }
873
901
  );
@@ -975,9 +1003,9 @@ var YDRZ = {
975
1003
  return Math.floor(Math.random() * (min - max) + max);
976
1004
  },
977
1005
  getUA() {
978
- const ua = nav.userAgent, l = [
1006
+ const ua2 = nav.userAgent, l = [
979
1007
  nav.platform,
980
- ua,
1008
+ ua2,
981
1009
  nav.appVersion,
982
1010
  nav.cookieEnabled,
983
1011
  void 0,
@@ -988,7 +1016,7 @@ var YDRZ = {
988
1016
  nav.availHeight,
989
1017
  nav.colorDepth,
990
1018
  nav.timezoneOffset
991
- ], key = l.join("@@"), finalUA = ua.length > 100 ? ua.substring(0, 100) : ua;
1019
+ ], key = l.join("@@"), finalUA = ua2.length > 100 ? ua2.substring(0, 100) : ua2;
992
1020
  return nav.platform + "@@" + finalUA + "@@" + md5(key);
993
1021
  },
994
1022
  uaE(str) {
@@ -1127,12 +1155,165 @@ var loginOneClick = {
1127
1155
  authn
1128
1156
  };
1129
1157
 
1158
+ // src/modules/login_phone.ts
1159
+ function randomString3() {
1160
+ const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
1161
+ return random.toLowerCase();
1162
+ }
1163
+ var loginPhone = {
1164
+ //获取验证码
1165
+ async getMsgCode(phone) {
1166
+ var $ = {
1167
+ "isAsync": true,
1168
+ "msisdn": "",
1169
+ "captcha": "",
1170
+ "sourceID": "220029",
1171
+ "imgcodeType": "2",
1172
+ "fingerPrint": "",
1173
+ "fingerPrintDetail": "",
1174
+ "_": ""
1175
+ };
1176
+ const result = await getPublicKey();
1177
+ const { publicExponent = "", modulus = "" } = result;
1178
+ var c = new RSAKey();
1179
+ c.setPublic(modulus, publicExponent);
1180
+ $.msisdn = c.encrypt(phone) || "";
1181
+ if (!$.msisdn) return { error: "encrypt error" };
1182
+ const fakeFingerprint = randomString3();
1183
+ $.fingerPrint = fakeFingerprint;
1184
+ $.fingerPrintDetail = fakeFingerprint;
1185
+ $._ = (/* @__PURE__ */ new Date()).getTime().toString();
1186
+ const query = URLParams($);
1187
+ const res = await fetch(
1188
+ `https://passport.migu.cn/login/dynamicpassword?${query}`,
1189
+ {
1190
+ method: "GET",
1191
+ headers: {
1192
+ "Host": "passport.migu.cn",
1193
+ "Referer": "https://passport.migu.cn/login",
1194
+ "Origin": "https://passport.migu.cn"
1195
+ }
1196
+ }
1197
+ );
1198
+ if (!res.ok) return { error: "gmc e" };
1199
+ const data = await res.json();
1200
+ return data;
1201
+ },
1202
+ //登陆
1203
+ async authn(phone, msgCode) {
1204
+ var $ = {
1205
+ "isAsync": true,
1206
+ "msisdn": "",
1207
+ "dynamicPassword": "",
1208
+ "captcha": "",
1209
+ "appType": "",
1210
+ "securityCode": "7619",
1211
+ "sourceID": "220029",
1212
+ "imgcodeType": "2",
1213
+ "fingerPrint": "",
1214
+ "fingerPrintDetail": ""
1215
+ };
1216
+ const result = await getPublicKey();
1217
+ const { publicExponent = "", modulus = "" } = result;
1218
+ var c = new RSAKey();
1219
+ c.setPublic(modulus, publicExponent);
1220
+ $.msisdn = c.encrypt(phone) || "";
1221
+ $.dynamicPassword = c.encrypt(msgCode) || "";
1222
+ if (!$.msisdn || !$.dynamicPassword) return { error: "encrypt error" };
1223
+ const fakeFingerprint = randomString3();
1224
+ $.fingerPrint = fakeFingerprint;
1225
+ $.fingerPrintDetail = fakeFingerprint;
1226
+ const form = URLParams($);
1227
+ const res = await fetch(
1228
+ `https://passport.migu.cn/authn/dynamicpassword`,
1229
+ {
1230
+ method: "POST",
1231
+ headers: {
1232
+ "Host": "passport.migu.cn",
1233
+ "Content-Type": "application/x-www-form-urlencoded",
1234
+ "Referer": "https://passport.migu.cn/login",
1235
+ "Origin": "https://passport.migu.cn"
1236
+ },
1237
+ body: form
1238
+ }
1239
+ );
1240
+ if (!res.ok) return { error: "gmc e" };
1241
+ const data = await res.json();
1242
+ return data;
1243
+ }
1244
+ };
1245
+
1246
+ // src/modules/mv_recommend.ts
1247
+ var getMVRecommend = async (mvContentId, page = 1) => {
1248
+ return await h5fetch(`https://c.musicapp.migu.cn/MIGUM3.0/v3.0/content/recommend-mv?resourceId=${mvContentId}&pageNumber=${page}&resourceType=D`);
1249
+ };
1250
+
1251
+ // src/modules/playlist_square.ts
1252
+ var getPlaylistSquare = async () => {
1253
+ return await h5fetch(`https://app.c.nf.migu.cn/pc/bmw/page-data/playlist-square-recommend/v1.0?templateVersion=2`);
1254
+ };
1255
+
1256
+ // src/modules/search_lrc.ts
1257
+ var searchLrc = async (text, page = 1) => {
1258
+ return await h5fetch(`http://app.c.nf.migu.cn/bmw/search/lrc/v1.0?pageNo=${page}&text=${text}`);
1259
+ };
1260
+
1261
+ // src/modules/ninan_song.ts
1262
+ var getNinanSong = async () => {
1263
+ return await h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/column/ninan/song-list/v1.0`);
1264
+ };
1265
+
1266
+ // src/modules/ninan_date.ts
1267
+ var getNinanByDate = async (date) => {
1268
+ return await h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v2.0/content/getNinanByDate.do?columnTitle=${date}`);
1269
+ };
1270
+
1271
+ // src/modules/recommend_radio_all.ts
1272
+ var getRadioRecommendAll = async (pacmtoken = "") => {
1273
+ return await h5fetch(
1274
+ `https://app.c.nf.migu.cn/pc/bmw/page-data/music-radio/v1.0?templateVersion=1`,
1275
+ {
1276
+ method: "GET",
1277
+ headers: {
1278
+ "Cookie": `pacmtoken=${pacmtoken}`
1279
+ }
1280
+ }
1281
+ );
1282
+ };
1283
+
1284
+ // src/utils/index.ts
1285
+ var utils_exports = {};
1286
+ __export(utils_exports, {
1287
+ RSAKey: () => RSAKey,
1288
+ URLParams: () => URLParams,
1289
+ getDeviceId: () => getDeviceId,
1290
+ getPublicKey: () => getPublicKey,
1291
+ randomUA: () => randomUA,
1292
+ ua: () => ua
1293
+ });
1294
+
1295
+ // src/utils/ua.ts
1296
+ var ua = [
1297
+ "Mozilla/5.0 (Linux; Android 9; Redmi Note 7 Build/PKQ1.180904.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/72.0.3626.121 Mobile Safari/537.36",
1298
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0",
1299
+ "Mozilla/5.0 (Linux; Android 9; Redmi Note 7 Build/PKQ1.180904.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.136 Mobile Safari/537.36",
1300
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Mobile/15B150 /sa-sdk-ios/sensors-verify/sc.baertt.com?production ",
1301
+ "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/534.31 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/534.31"
1302
+ ];
1303
+ var randomUA = () => {
1304
+ const i = Math.floor(Math.random() * 5);
1305
+ return ua[i];
1306
+ };
1307
+
1130
1308
  // src/index.ts
1131
1309
  function createClient() {
1132
1310
  return modules_exports;
1133
1311
  }
1134
1312
  // Annotate the CommonJS export names for ESM import in node:
1135
1313
  0 && (module.exports = {
1314
+ MiguUtils,
1315
+ RSAKey,
1316
+ URLParams,
1136
1317
  YDRZ,
1137
1318
  checkCanListen,
1138
1319
  checkToken,
@@ -1140,13 +1321,20 @@ function createClient() {
1140
1321
  getAlbumInfo,
1141
1322
  getAlbumSong,
1142
1323
  getComment,
1324
+ getDeviceId,
1325
+ getMVRecommend,
1143
1326
  getMvHls,
1144
1327
  getMvInfo,
1328
+ getNinanByDate,
1329
+ getNinanSong,
1145
1330
  getOpNum,
1146
1331
  getPacmToken,
1147
1332
  getPlaylistInfo,
1148
1333
  getPlaylistSong,
1334
+ getPlaylistSquare,
1335
+ getPublicKey,
1149
1336
  getRadioRecommend,
1337
+ getRadioRecommendAll,
1150
1338
  getRankIndex,
1151
1339
  getRankInfo,
1152
1340
  getRecommendPlaylist,
@@ -1173,16 +1361,20 @@ function createClient() {
1173
1361
  getVersion,
1174
1362
  loginNP,
1175
1363
  loginOneClick,
1364
+ loginPhone,
1176
1365
  loginSim,
1177
1366
  modules,
1178
1367
  queryUserInfo,
1368
+ randomUA,
1179
1369
  searchAlbum,
1180
1370
  searchConcert,
1371
+ searchLrc,
1181
1372
  searchRbt,
1182
1373
  searchSinger,
1183
1374
  searchSong,
1184
1375
  searchSuggest,
1185
1376
  searchTicket,
1186
- searchVideo
1377
+ searchVideo,
1378
+ ua
1187
1379
  });
1188
1380
  //# sourceMappingURL=index.cjs.map