migu-api-enhanced 1.2.1 → 1.2.3

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.js CHANGED
@@ -8,17 +8,22 @@ var __export = (target, all) => {
8
8
  var modules_exports = {};
9
9
  __export(modules_exports, {
10
10
  checkCanListen: () => checkCanListen,
11
+ checkToken: () => checkToken,
11
12
  getAlbumInfo: () => getAlbumInfo,
12
13
  getAlbumSong: () => getAlbumSong,
13
14
  getComment: () => getComment,
15
+ getMvHls: () => getMvHls,
16
+ getMvInfo: () => getMvInfo,
14
17
  getOpNum: () => getOpNum,
18
+ getPacmToken: () => getPacmToken,
15
19
  getPlaylistInfo: () => getPlaylistInfo,
16
20
  getPlaylistSong: () => getPlaylistSong,
21
+ getRadioRecommend: () => getRadioRecommend,
17
22
  getRankIndex: () => getRankIndex,
18
23
  getRankInfo: () => getRankInfo,
19
24
  getRecommendPlaylist: () => getRecommendPlaylist,
20
- getRecommendSong: () => getRecommendSong,
21
25
  getResourceInfo: () => getResourceInfo,
26
+ getSceneRecommend: () => getSceneRecommend,
22
27
  getSearchDefault: () => getSearchDefault,
23
28
  getSearchHot: () => getSearchHot,
24
29
  getSearchSingerTab: () => getSearchSingerTab,
@@ -26,10 +31,16 @@ __export(modules_exports, {
26
31
  getSingerAlbum: () => getSingerAlbum,
27
32
  getSingerIndex: () => getSingerIndex,
28
33
  getSingerSong: () => getSingerSong,
34
+ getTicketInfo: () => getTicketInfo,
35
+ getTodayRecommend: () => getTodayRecommend,
29
36
  getUrlH5V24: () => getUrlH5V24,
30
37
  getUrlV1: () => getUrlV1,
31
38
  getUrlV2: () => getUrlV2,
39
+ getUserBadge: () => getUserBadge,
40
+ getUserHomePage: () => getUserHomePage,
32
41
  getVersion: () => getVersion,
42
+ loginNP: () => loginNP,
43
+ queryUserInfo: () => queryUserInfo,
33
44
  searchAlbum: () => searchAlbum,
34
45
  searchConcert: () => searchConcert,
35
46
  searchRbt: () => searchRbt,
@@ -172,14 +183,55 @@ var getRecommendPlaylist = async () => {
172
183
  return await h5fetch(`http://app.c.nf.migu.cn/bmw/index-show/recommend-playlist/v3.0`);
173
184
  };
174
185
 
186
+ // src/utils/deviceID.ts
187
+ function getDeviceId() {
188
+ const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
189
+ const a = `${random.substring(0, 8)}-${random.substring(8, 12)}-${random.substring(12, 16)}-${random.substring(16, 20)}-${random.substring(20)}`;
190
+ return a.toUpperCase();
191
+ }
192
+
175
193
  // src/modules/recommend_song.ts
176
- var getRecommendSong = async (size = 20, scene = "TODAY_RECOMMEND") => {
177
- return await h5fetch(`http://app.c.nf.migu.cn/resource-dataloader/recommend-song/v1.0?actionId=1&scene=${scene}&size=${size}`);
194
+ var getSceneRecommend = async (scene = "TODAY_RECOMMEND", size = 10) => {
195
+ let params = "";
196
+ if (scene === "PRIVATE_FM") {
197
+ params = "scene=PRIVATE_FM&algorithm=v1&action=1";
198
+ } else if (scene === "TODAY_RECOMMEND") {
199
+ params = `scene=TODAY_RECOMMEND&action=1&size=${size}`;
200
+ } else {
201
+ return { error: "scene\u53C2\u6570\u9519\u8BEF" };
202
+ }
203
+ return await h5fetch(
204
+ `https://app.c.nf.migu.cn/pc/resource-dataloader/recommend-song/v1.0?${params}`,
205
+ {
206
+ headers: {
207
+ "deviceId": getDeviceId()
208
+ }
209
+ }
210
+ );
211
+ };
212
+
213
+ // src/modules/recommend_radio.ts
214
+ var getRadioRecommend = async (type = 1) => {
215
+ if (type !== 1 && type !== 2) {
216
+ return { error: "type must be 1 or 2" };
217
+ }
218
+ return await h5fetch(
219
+ `https://app.c.nf.migu.cn/pc/column/music-radio/recommend/song/v2.0?remain=0&actionId=1&type=${type}`,
220
+ {
221
+ method: "GET",
222
+ headers: {
223
+ "Referer": "https://music.migu.cn/",
224
+ "channel": "014X031",
225
+ "deviceId": getDeviceId(),
226
+ "recommendstatus": "1"
227
+ }
228
+ }
229
+ );
178
230
  };
179
231
 
180
232
  // src/modules/comment.ts
181
- var getComment = async (resourceId, resourceType = 2, hotCommentStart = 0, size = 20) => {
182
- return await h5fetch(`https://app.u.nf.migu.cn/MIGUM3.0/user/comment/stack/v1.0?hotCommentStart=${hotCommentStart}&pageSize=${size}&queryType=1&resourceId=${resourceId}&resourceType=${resourceType}`);
233
+ var getComment = async (resourceId, resourceType = 2, size = 20, hotCommentStart = 0) => {
234
+ return await h5fetch(`https://u.musicapp.migu.cn/MIGUM3.0/user/comment/stack/v1.0?resourceId=${resourceId}&resourceType=${resourceType}&pageSize=${size}&hotCommentStart=${hotCommentStart}&platformType=1&commentId=0&queryType=1`);
183
235
  };
184
236
 
185
237
  // src/modules/resourceinfo.ts
@@ -219,7 +271,7 @@ var getUrlV1 = async (contentId, copyrightId, resourceType = "2") => {
219
271
  };
220
272
 
221
273
  // src/modules/url_v2.ts
222
- var getUrlV2 = async (contentId, copyrightId, resourceType = "2") => {
274
+ var getUrlV2 = async (contentId, copyrightId, resourceType = "2", pacmtoken = "") => {
223
275
  const deviceId = getDeviceId();
224
276
  const timestamp = Date.now();
225
277
  const headers = {
@@ -229,7 +281,7 @@ var getUrlV2 = async (contentId, copyrightId, resourceType = "2") => {
229
281
  "subchannel": "014X031",
230
282
  "logId": "cfrom=&appId=h5",
231
283
  "uid": "",
232
- "pacmtoken": "",
284
+ "pacmtoken": pacmtoken,
233
285
  "appId": "h5",
234
286
  "platform": "H5",
235
287
  "deviceId": deviceId,
@@ -256,11 +308,6 @@ var SECURE = "Jk8qzuePiJ1qE3mDYhLQ3T73DtDoAhLP";
256
308
  var aw = 171;
257
309
  var iw = 205;
258
310
  var ow = 1;
259
- function getDeviceId() {
260
- const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
261
- const a = `${random.substring(0, 8)}-${random.substring(8, 12)}-${random.substring(12, 16)}-${random.substring(16, 20)}-${random.substring(20)}`;
262
- return a.toUpperCase();
263
- }
264
311
  function textEncode(e) {
265
312
  return new TextEncoder().encode(e);
266
313
  }
@@ -371,24 +418,712 @@ var getVersion = async (channel = "0146921", version = "8.4.0", ua = "Android_mi
371
418
  );
372
419
  };
373
420
 
421
+ // src/modules/mv_info.ts
422
+ var getMvInfo = async (mvIds, {
423
+ needAbsoluteUrl = false
424
+ }) => {
425
+ const res = await h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvIds}&resourceType=D&needSimple=01`);
426
+ if (!res) return { error: "\u8BF7\u6C42\u5931\u8D25" };
427
+ if (res.error) return { error: res.error };
428
+ const resource = res.resource || [];
429
+ if (resource.length === 0) return { error: "resource\u4E0D\u5B58\u5728" };
430
+ if (needAbsoluteUrl) {
431
+ resource.forEach((item) => {
432
+ if (!item.rateFormats) return;
433
+ item.rateFormats.forEach((rateFormat) => {
434
+ if (!rateFormat.url) return;
435
+ if (!rateFormat.url.startsWith("http") && !rateFormat.url.startsWith("https")) {
436
+ if (rateFormat.url[0] === "/" && rateFormat.url[1] !== "/") {
437
+ rateFormat.absoluteUrl = `https://freevod.nf.migu.cn${rateFormat.url}`;
438
+ }
439
+ }
440
+ });
441
+ });
442
+ res.resource = resource;
443
+ return res;
444
+ }
445
+ return res;
446
+ };
447
+
448
+ // src/modules/mv_hls.ts
449
+ var getMvHls = async (mvContentId, mvCopyrightId, url, size, format = "050012", needHttps = true) => {
450
+ size = size.toString();
451
+ url = encodeURIComponent(url);
452
+ return await h5fetch(
453
+ `https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/mvplayinfo.do?format=${format}&mvContentId=${mvContentId}&mvCopyrightId=${mvCopyrightId}&needHttps=${needHttps}&size=${size}&url=${url}`,
454
+ {
455
+ method: "GET",
456
+ headers: {
457
+ "Channel": "014021I"
458
+ }
459
+ }
460
+ );
461
+ };
462
+
463
+ // src/utils/rsalib.js
464
+ import crypto from "crypto";
465
+ var rsa;
466
+ globalThis.define = function(id, deps, factory) {
467
+ let req = () => ({});
468
+ let exp = {};
469
+ let mod = { exports: exp };
470
+ factory(req, exp, mod);
471
+ rsa = mod.exports;
472
+ };
473
+ globalThis.window = {};
474
+ Object.defineProperty(globalThis, "navigator", {
475
+ writable: true,
476
+ value: {
477
+ appName: "Netscape",
478
+ appVersion: "5.0 (Node.js)"
479
+ }
480
+ });
481
+ globalThis.window.navigator = globalThis.navigator;
482
+ globalThis.window.crypto = {
483
+ getRandomValues: function(arr) {
484
+ const bytes = crypto.randomBytes(arr.length);
485
+ for (let i = 0; i < arr.length; i++) {
486
+ arr[i] = bytes[i];
487
+ }
488
+ return arr;
489
+ },
490
+ random: function(len) {
491
+ const bytes = crypto.randomBytes(len);
492
+ return Array.from(bytes, (b) => String.fromCharCode(b)).join("");
493
+ }
494
+ };
495
+ define("lib/rsa/rsa", [], function(a, b, c) {
496
+ function d(a2, b2, c2) {
497
+ null != a2 && ("number" == typeof a2 ? this.fromNumber(a2, b2, c2) : null == b2 && "string" != typeof a2 ? this.fromString(a2, 256) : this.fromString(a2, b2));
498
+ }
499
+ function e() {
500
+ return new d(null);
501
+ }
502
+ function f(a2, b2, c2, d2, e2, f2) {
503
+ for (; --f2 >= 0; ) {
504
+ var g2 = b2 * this[a2++] + c2[d2] + e2;
505
+ e2 = Math.floor(g2 / 67108864), c2[d2++] = 67108863 & g2;
506
+ }
507
+ return e2;
508
+ }
509
+ function g(a2, b2, c2, d2, e2, f2) {
510
+ for (var g2 = 32767 & b2, h2 = b2 >> 15; --f2 >= 0; ) {
511
+ var i2 = 32767 & this[a2], j2 = this[a2++] >> 15, k2 = h2 * i2 + j2 * g2;
512
+ i2 = g2 * i2 + ((32767 & k2) << 15) + c2[d2] + (1073741823 & e2), e2 = (i2 >>> 30) + (k2 >>> 15) + h2 * j2 + (e2 >>> 30), c2[d2++] = 1073741823 & i2;
513
+ }
514
+ return e2;
515
+ }
516
+ function h(a2, b2, c2, d2, e2, f2) {
517
+ for (var g2 = 16383 & b2, h2 = b2 >> 14; --f2 >= 0; ) {
518
+ var i2 = 16383 & this[a2], j2 = this[a2++] >> 14, k2 = h2 * i2 + j2 * g2;
519
+ i2 = g2 * i2 + ((16383 & k2) << 14) + c2[d2] + e2, e2 = (i2 >> 28) + (k2 >> 14) + h2 * j2, c2[d2++] = 268435455 & i2;
520
+ }
521
+ return e2;
522
+ }
523
+ function i(a2) {
524
+ return nb.charAt(a2);
525
+ }
526
+ function j(a2, b2) {
527
+ var c2 = ob[a2.charCodeAt(b2)];
528
+ return null == c2 ? -1 : c2;
529
+ }
530
+ function k(a2) {
531
+ for (var b2 = this.t - 1; b2 >= 0; --b2)
532
+ a2[b2] = this[b2];
533
+ a2.t = this.t, a2.s = this.s;
534
+ }
535
+ function l(a2) {
536
+ this.t = 1, this.s = 0 > a2 ? -1 : 0, a2 > 0 ? this[0] = a2 : -1 > a2 ? this[0] = a2 + this.DV : this.t = 0;
537
+ }
538
+ function m(a2) {
539
+ var b2 = e();
540
+ return b2.fromInt(a2), b2;
541
+ }
542
+ function n(a2, b2) {
543
+ var c2;
544
+ if (16 == b2)
545
+ c2 = 4;
546
+ else if (8 == b2)
547
+ c2 = 3;
548
+ else if (256 == b2)
549
+ c2 = 8;
550
+ else if (2 == b2)
551
+ c2 = 1;
552
+ else if (32 == b2)
553
+ c2 = 5;
554
+ else {
555
+ if (4 != b2)
556
+ return void this.fromRadix(a2, b2);
557
+ c2 = 2;
558
+ }
559
+ this.t = 0, this.s = 0;
560
+ for (var e2 = a2.length, f2 = false, g2 = 0; --e2 >= 0; ) {
561
+ var h2 = 8 == c2 ? 255 & a2[e2] : j(a2, e2);
562
+ 0 > h2 ? "-" == a2.charAt(e2) && (f2 = true) : (f2 = false, 0 == g2 ? this[this.t++] = h2 : g2 + c2 > this.DB ? (this[this.t - 1] |= (h2 & (1 << this.DB - g2) - 1) << g2, this[this.t++] = h2 >> this.DB - g2) : this[this.t - 1] |= h2 << g2, g2 += c2, g2 >= this.DB && (g2 -= this.DB));
563
+ }
564
+ 8 == c2 && 0 != (128 & a2[0]) && (this.s = -1, g2 > 0 && (this[this.t - 1] |= (1 << this.DB - g2) - 1 << g2)), this.clamp(), f2 && d.ZERO.subTo(this, this);
565
+ }
566
+ function o() {
567
+ for (var a2 = this.s & this.DM; this.t > 0 && this[this.t - 1] == a2; )
568
+ --this.t;
569
+ }
570
+ function p(a2) {
571
+ if (this.s < 0)
572
+ return "-" + this.negate().toString(a2);
573
+ var b2;
574
+ if (16 == a2)
575
+ b2 = 4;
576
+ else if (8 == a2)
577
+ b2 = 3;
578
+ else if (2 == a2)
579
+ b2 = 1;
580
+ else if (32 == a2)
581
+ b2 = 5;
582
+ else {
583
+ if (4 != a2)
584
+ return this.toRadix(a2);
585
+ b2 = 2;
586
+ }
587
+ var c2, d2 = (1 << b2) - 1, e2 = false, f2 = "", g2 = this.t, h2 = this.DB - g2 * this.DB % b2;
588
+ if (g2-- > 0)
589
+ for (h2 < this.DB && (c2 = this[g2] >> h2) > 0 && (e2 = true, f2 = i(c2)); g2 >= 0; )
590
+ b2 > h2 ? (c2 = (this[g2] & (1 << h2) - 1) << b2 - h2, c2 |= this[--g2] >> (h2 += this.DB - b2)) : (c2 = this[g2] >> (h2 -= b2) & d2, 0 >= h2 && (h2 += this.DB, --g2)), c2 > 0 && (e2 = true), e2 && (f2 += i(c2));
591
+ return e2 ? f2 : "0";
592
+ }
593
+ function q() {
594
+ var a2 = e();
595
+ return d.ZERO.subTo(this, a2), a2;
596
+ }
597
+ function r() {
598
+ return this.s < 0 ? this.negate() : this;
599
+ }
600
+ function s(a2) {
601
+ var b2 = this.s - a2.s;
602
+ if (0 != b2)
603
+ return b2;
604
+ var c2 = this.t;
605
+ if (b2 = c2 - a2.t, 0 != b2)
606
+ return this.s < 0 ? -b2 : b2;
607
+ for (; --c2 >= 0; )
608
+ if (0 != (b2 = this[c2] - a2[c2]))
609
+ return b2;
610
+ return 0;
611
+ }
612
+ function t(a2) {
613
+ var b2, c2 = 1;
614
+ return 0 != (b2 = a2 >>> 16) && (a2 = b2, c2 += 16), 0 != (b2 = a2 >> 8) && (a2 = b2, c2 += 8), 0 != (b2 = a2 >> 4) && (a2 = b2, c2 += 4), 0 != (b2 = a2 >> 2) && (a2 = b2, c2 += 2), 0 != (b2 = a2 >> 1) && (a2 = b2, c2 += 1), c2;
615
+ }
616
+ function u() {
617
+ return this.t <= 0 ? 0 : this.DB * (this.t - 1) + t(this[this.t - 1] ^ this.s & this.DM);
618
+ }
619
+ function v(a2, b2) {
620
+ var c2;
621
+ for (c2 = this.t - 1; c2 >= 0; --c2)
622
+ b2[c2 + a2] = this[c2];
623
+ for (c2 = a2 - 1; c2 >= 0; --c2)
624
+ b2[c2] = 0;
625
+ b2.t = this.t + a2, b2.s = this.s;
626
+ }
627
+ function w(a2, b2) {
628
+ for (var c2 = a2; c2 < this.t; ++c2)
629
+ b2[c2 - a2] = this[c2];
630
+ b2.t = Math.max(this.t - a2, 0), b2.s = this.s;
631
+ }
632
+ function x(a2, b2) {
633
+ var c2, d2 = a2 % this.DB, e2 = this.DB - d2, f2 = (1 << e2) - 1, g2 = Math.floor(a2 / this.DB), h2 = this.s << d2 & this.DM;
634
+ for (c2 = this.t - 1; c2 >= 0; --c2)
635
+ b2[c2 + g2 + 1] = this[c2] >> e2 | h2, h2 = (this[c2] & f2) << d2;
636
+ for (c2 = g2 - 1; c2 >= 0; --c2)
637
+ b2[c2] = 0;
638
+ b2[g2] = h2, b2.t = this.t + g2 + 1, b2.s = this.s, b2.clamp();
639
+ }
640
+ function y(a2, b2) {
641
+ b2.s = this.s;
642
+ var c2 = Math.floor(a2 / this.DB);
643
+ if (c2 >= this.t)
644
+ return void (b2.t = 0);
645
+ var d2 = a2 % this.DB, e2 = this.DB - d2, f2 = (1 << d2) - 1;
646
+ b2[0] = this[c2] >> d2;
647
+ for (var g2 = c2 + 1; g2 < this.t; ++g2)
648
+ b2[g2 - c2 - 1] |= (this[g2] & f2) << e2, b2[g2 - c2] = this[g2] >> d2;
649
+ d2 > 0 && (b2[this.t - c2 - 1] |= (this.s & f2) << e2), b2.t = this.t - c2, b2.clamp();
650
+ }
651
+ function z(a2, b2) {
652
+ for (var c2 = 0, d2 = 0, e2 = Math.min(a2.t, this.t); e2 > c2; )
653
+ d2 += this[c2] - a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
654
+ if (a2.t < this.t) {
655
+ for (d2 -= a2.s; c2 < this.t; )
656
+ d2 += this[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
657
+ d2 += this.s;
658
+ } else {
659
+ for (d2 += this.s; c2 < a2.t; )
660
+ d2 -= a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
661
+ d2 -= a2.s;
662
+ }
663
+ b2.s = 0 > d2 ? -1 : 0, -1 > d2 ? b2[c2++] = this.DV + d2 : d2 > 0 && (b2[c2++] = d2), b2.t = c2, b2.clamp();
664
+ }
665
+ function A(a2, b2) {
666
+ var c2 = this.abs(), e2 = a2.abs(), f2 = c2.t;
667
+ for (b2.t = f2 + e2.t; --f2 >= 0; )
668
+ b2[f2] = 0;
669
+ for (f2 = 0; f2 < e2.t; ++f2)
670
+ b2[f2 + c2.t] = c2.am(0, e2[f2], b2, f2, 0, c2.t);
671
+ b2.s = 0, b2.clamp(), this.s != a2.s && d.ZERO.subTo(b2, b2);
672
+ }
673
+ function B(a2) {
674
+ for (var b2 = this.abs(), c2 = a2.t = 2 * b2.t; --c2 >= 0; )
675
+ a2[c2] = 0;
676
+ for (c2 = 0; c2 < b2.t - 1; ++c2) {
677
+ var d2 = b2.am(c2, b2[c2], a2, 2 * c2, 0, 1);
678
+ (a2[c2 + b2.t] += b2.am(c2 + 1, 2 * b2[c2], a2, 2 * c2 + 1, d2, b2.t - c2 - 1)) >= b2.DV && (a2[c2 + b2.t] -= b2.DV, a2[c2 + b2.t + 1] = 1);
679
+ }
680
+ a2.t > 0 && (a2[a2.t - 1] += b2.am(c2, b2[c2], a2, 2 * c2, 0, 1)), a2.s = 0, a2.clamp();
681
+ }
682
+ function C(a2, b2, c2) {
683
+ var f2 = a2.abs();
684
+ if (!(f2.t <= 0)) {
685
+ var g2 = this.abs();
686
+ if (g2.t < f2.t)
687
+ return null != b2 && b2.fromInt(0), void (null != c2 && this.copyTo(c2));
688
+ null == c2 && (c2 = e());
689
+ var h2 = e(), i2 = this.s, j2 = a2.s, k2 = this.DB - t(f2[f2.t - 1]);
690
+ k2 > 0 ? (f2.lShiftTo(k2, h2), g2.lShiftTo(k2, c2)) : (f2.copyTo(h2), g2.copyTo(c2));
691
+ var l2 = h2.t, m2 = h2[l2 - 1];
692
+ if (0 != m2) {
693
+ var n2 = m2 * (1 << this.F1) + (l2 > 1 ? h2[l2 - 2] >> this.F2 : 0), o2 = this.FV / n2, p2 = (1 << this.F1) / n2, q2 = 1 << this.F2, r2 = c2.t, s2 = r2 - l2, u2 = null == b2 ? e() : b2;
694
+ for (h2.dlShiftTo(s2, u2), c2.compareTo(u2) >= 0 && (c2[c2.t++] = 1, c2.subTo(u2, c2)), d.ONE.dlShiftTo(l2, u2), u2.subTo(h2, h2); h2.t < l2; )
695
+ h2[h2.t++] = 0;
696
+ for (; --s2 >= 0; ) {
697
+ var v2 = c2[--r2] == m2 ? this.DM : Math.floor(c2[r2] * o2 + (c2[r2 - 1] + q2) * p2);
698
+ if ((c2[r2] += h2.am(0, v2, c2, s2, 0, l2)) < v2)
699
+ for (h2.dlShiftTo(s2, u2), c2.subTo(u2, c2); c2[r2] < --v2; )
700
+ c2.subTo(u2, c2);
701
+ }
702
+ null != b2 && (c2.drShiftTo(l2, b2), i2 != j2 && d.ZERO.subTo(b2, b2)), c2.t = l2, c2.clamp(), k2 > 0 && c2.rShiftTo(k2, c2), 0 > i2 && d.ZERO.subTo(c2, c2);
703
+ }
704
+ }
705
+ }
706
+ function D(a2) {
707
+ var b2 = e();
708
+ return this.abs().divRemTo(a2, null, b2), this.s < 0 && b2.compareTo(d.ZERO) > 0 && a2.subTo(b2, b2), b2;
709
+ }
710
+ function E(a2) {
711
+ this.m = a2;
712
+ }
713
+ function F(a2) {
714
+ return a2.s < 0 || a2.compareTo(this.m) >= 0 ? a2.mod(this.m) : a2;
715
+ }
716
+ function G(a2) {
717
+ return a2;
718
+ }
719
+ function H(a2) {
720
+ a2.divRemTo(this.m, null, a2);
721
+ }
722
+ function I(a2, b2, c2) {
723
+ a2.multiplyTo(b2, c2), this.reduce(c2);
724
+ }
725
+ function J(a2, b2) {
726
+ a2.squareTo(b2), this.reduce(b2);
727
+ }
728
+ function K() {
729
+ if (this.t < 1)
730
+ return 0;
731
+ var a2 = this[0];
732
+ if (0 == (1 & a2))
733
+ return 0;
734
+ var b2 = 3 & a2;
735
+ return b2 = b2 * (2 - (15 & a2) * b2) & 15, b2 = b2 * (2 - (255 & a2) * b2) & 255, b2 = b2 * (2 - ((65535 & a2) * b2 & 65535)) & 65535, b2 = b2 * (2 - a2 * b2 % this.DV) % this.DV, b2 > 0 ? this.DV - b2 : -b2;
736
+ }
737
+ function L(a2) {
738
+ this.m = a2, this.mp = a2.invDigit(), this.mpl = 32767 & this.mp, this.mph = this.mp >> 15, this.um = (1 << a2.DB - 15) - 1, this.mt2 = 2 * a2.t;
739
+ }
740
+ function M(a2) {
741
+ var b2 = e();
742
+ return a2.abs().dlShiftTo(this.m.t, b2), b2.divRemTo(this.m, null, b2), a2.s < 0 && b2.compareTo(d.ZERO) > 0 && this.m.subTo(b2, b2), b2;
743
+ }
744
+ function N(a2) {
745
+ var b2 = e();
746
+ return a2.copyTo(b2), this.reduce(b2), b2;
747
+ }
748
+ function O(a2) {
749
+ for (; a2.t <= this.mt2; )
750
+ a2[a2.t++] = 0;
751
+ for (var b2 = 0; b2 < this.m.t; ++b2) {
752
+ var c2 = 32767 & a2[b2], d2 = c2 * this.mpl + ((c2 * this.mph + (a2[b2] >> 15) * this.mpl & this.um) << 15) & a2.DM;
753
+ for (c2 = b2 + this.m.t, a2[c2] += this.m.am(0, d2, a2, b2, 0, this.m.t); a2[c2] >= a2.DV; )
754
+ a2[c2] -= a2.DV, a2[++c2]++;
755
+ }
756
+ a2.clamp(), a2.drShiftTo(this.m.t, a2), a2.compareTo(this.m) >= 0 && a2.subTo(this.m, a2);
757
+ }
758
+ function P(a2, b2) {
759
+ a2.squareTo(b2), this.reduce(b2);
760
+ }
761
+ function Q(a2, b2, c2) {
762
+ a2.multiplyTo(b2, c2), this.reduce(c2);
763
+ }
764
+ function R() {
765
+ return 0 == (this.t > 0 ? 1 & this[0] : this.s);
766
+ }
767
+ function S(a2, b2) {
768
+ if (a2 > 4294967295 || 1 > a2)
769
+ return d.ONE;
770
+ var c2 = e(), f2 = e(), g2 = b2.convert(this), h2 = t(a2) - 1;
771
+ for (g2.copyTo(c2); --h2 >= 0; )
772
+ if (b2.sqrTo(c2, f2), (a2 & 1 << h2) > 0)
773
+ b2.mulTo(f2, g2, c2);
774
+ else {
775
+ var i2 = c2;
776
+ c2 = f2, f2 = i2;
777
+ }
778
+ return b2.revert(c2);
779
+ }
780
+ function T(a2, b2) {
781
+ var c2;
782
+ return c2 = 256 > a2 || b2.isEven() ? new E(b2) : new L(b2), this.exp(a2, c2);
783
+ }
784
+ function U() {
785
+ this.i = 0, this.j = 0, this.S = new Array();
786
+ }
787
+ function V(a2) {
788
+ var b2, c2, d2;
789
+ for (b2 = 0; 256 > b2; ++b2)
790
+ this.S[b2] = b2;
791
+ for (c2 = 0, b2 = 0; 256 > b2; ++b2)
792
+ c2 = c2 + this.S[b2] + a2[b2 % a2.length] & 255, d2 = this.S[b2], this.S[b2] = this.S[c2], this.S[c2] = d2;
793
+ this.i = 0, this.j = 0;
794
+ }
795
+ function W() {
796
+ var a2;
797
+ return this.i = this.i + 1 & 255, this.j = this.j + this.S[this.i] & 255, a2 = this.S[this.i], this.S[this.i] = this.S[this.j], this.S[this.j] = a2, this.S[a2 + this.S[this.i] & 255];
798
+ }
799
+ function X() {
800
+ return new U();
801
+ }
802
+ function Y(a2) {
803
+ qb[rb++] ^= 255 & a2, qb[rb++] ^= a2 >> 8 & 255, qb[rb++] ^= a2 >> 16 & 255, qb[rb++] ^= a2 >> 24 & 255, rb >= sb && (rb -= sb);
804
+ }
805
+ function Z() {
806
+ Y((/* @__PURE__ */ new Date()).getTime());
807
+ }
808
+ function $() {
809
+ if (null == pb) {
810
+ for (Z(), pb = X(), pb.init(qb), rb = 0; rb < qb.length; ++rb)
811
+ qb[rb] = 0;
812
+ rb = 0;
813
+ }
814
+ return pb.next();
815
+ }
816
+ function _(a2) {
817
+ var b2;
818
+ for (b2 = 0; b2 < a2.length; ++b2)
819
+ a2[b2] = $();
820
+ }
821
+ function ab() {
822
+ }
823
+ function bb(a2, b2) {
824
+ return new d(a2, b2);
825
+ }
826
+ function cb(a2, b2) {
827
+ if (b2 < a2.length + 11)
828
+ return console.error("Message too long for RSA"), null;
829
+ for (var c2 = new Array(), e2 = a2.length - 1; e2 >= 0 && b2 > 0; ) {
830
+ var f2 = a2.charCodeAt(e2--);
831
+ 128 > f2 ? c2[--b2] = f2 : f2 > 127 && 2048 > f2 ? (c2[--b2] = 63 & f2 | 128, c2[--b2] = f2 >> 6 | 192) : (c2[--b2] = 63 & f2 | 128, c2[--b2] = f2 >> 6 & 63 | 128, c2[--b2] = f2 >> 12 | 224);
832
+ }
833
+ c2[--b2] = 0;
834
+ for (var g2 = new ab(), h2 = new Array(); b2 > 2; ) {
835
+ for (h2[0] = 0; 0 == h2[0]; )
836
+ g2.nextBytes(h2);
837
+ c2[--b2] = h2[0];
838
+ }
839
+ return c2[--b2] = 2, c2[--b2] = 0, new d(c2);
840
+ }
841
+ function db() {
842
+ this.n = null, this.e = 0, this.d = null, this.p = null, this.q = null, this.dmp1 = null, this.dmq1 = null, this.coeff = null;
843
+ }
844
+ function eb(a2, b2) {
845
+ null != a2 && null != b2 && a2.length > 0 && b2.length > 0 ? (this.n = bb(a2, 16), this.e = parseInt(b2, 16)) : console.error("net error");
846
+ }
847
+ function fb(a2) {
848
+ return a2.modPowInt(this.e, this.n);
849
+ }
850
+ function gb(a2) {
851
+ var b2 = cb(a2, this.n.bitLength() + 7 >> 3);
852
+ if (null == b2)
853
+ return null;
854
+ var c2 = this.doPublic(b2);
855
+ if (null == c2)
856
+ return null;
857
+ var d2 = c2.toString(16);
858
+ return 0 == (1 & d2.length) ? d2 : "0" + d2;
859
+ }
860
+ var hb, ib = 244837814094590, jb = 15715070 == (16777215 & ib);
861
+ jb && "Microsoft Internet Explorer" == navigator.appName ? (d.prototype.am = g, hb = 30) : jb && "Netscape" != navigator.appName ? (d.prototype.am = f, hb = 26) : (d.prototype.am = h, hb = 28), d.prototype.DB = hb, d.prototype.DM = (1 << hb) - 1, d.prototype.DV = 1 << hb;
862
+ var kb = 52;
863
+ d.prototype.FV = Math.pow(2, kb), d.prototype.F1 = kb - hb, d.prototype.F2 = 2 * hb - kb;
864
+ var lb, mb, nb = "0123456789abcdefghijklmnopqrstuvwxyz", ob = new Array();
865
+ for (lb = "0".charCodeAt(0), mb = 0; 9 >= mb; ++mb)
866
+ ob[lb++] = mb;
867
+ for (lb = "a".charCodeAt(0), mb = 10; 36 > mb; ++mb)
868
+ ob[lb++] = mb;
869
+ for (lb = "A".charCodeAt(0), mb = 10; 36 > mb; ++mb)
870
+ ob[lb++] = mb;
871
+ E.prototype.convert = F, E.prototype.revert = G, E.prototype.reduce = H, E.prototype.mulTo = I, E.prototype.sqrTo = J, L.prototype.convert = M, L.prototype.revert = N, L.prototype.reduce = O, L.prototype.mulTo = Q, L.prototype.sqrTo = P, d.prototype.copyTo = k, d.prototype.fromInt = l, d.prototype.fromString = n, d.prototype.clamp = o, d.prototype.dlShiftTo = v, d.prototype.drShiftTo = w, d.prototype.lShiftTo = x, d.prototype.rShiftTo = y, d.prototype.subTo = z, d.prototype.multiplyTo = A, d.prototype.squareTo = B, d.prototype.divRemTo = C, d.prototype.invDigit = K, d.prototype.isEven = R, d.prototype.exp = S, d.prototype.toString = p, d.prototype.negate = q, d.prototype.abs = r, d.prototype.compareTo = s, d.prototype.bitLength = u, d.prototype.mod = D, d.prototype.modPowInt = T, d.ZERO = m(0), d.ONE = m(1), U.prototype.init = V, U.prototype.next = W;
872
+ var pb, qb, rb, sb = 256;
873
+ if (null == qb) {
874
+ qb = new Array(), rb = 0;
875
+ var tb;
876
+ if (window.crypto && window.crypto.getRandomValues) {
877
+ var ub = new Uint8Array(32);
878
+ for (window.crypto.getRandomValues(ub), tb = 0; 32 > tb; ++tb)
879
+ qb[rb++] = ub[tb];
880
+ }
881
+ if ("Netscape" == navigator.appName && navigator.appVersion < "5" && window.crypto) {
882
+ var vb = window.crypto.random(32);
883
+ for (tb = 0; tb < vb.length; ++tb)
884
+ qb[rb++] = 255 & vb.charCodeAt(tb);
885
+ }
886
+ for (; sb > rb; )
887
+ tb = Math.floor(65536 * Math.random()), qb[rb++] = tb >>> 8, qb[rb++] = 255 & tb;
888
+ rb = 0, Z();
889
+ }
890
+ ab.prototype.nextBytes = _, db.prototype.doPublic = fb, db.prototype.setPublic = eb, db.prototype.encrypt = gb, c.exports = {
891
+ RSAKey: db
892
+ };
893
+ });
894
+ var rsalib_default = rsa;
895
+
896
+ // src/utils/publicKey.ts
897
+ var getPublicKey = async () => {
898
+ const res = await fetch(
899
+ "https://passport.migu.cn/password/publickey",
900
+ {
901
+ method: "POST"
902
+ }
903
+ );
904
+ if (!res.ok) return;
905
+ const data = await res.json();
906
+ const publicExponent = data.result.publicExponent;
907
+ const modulus = data.result.modulus;
908
+ return { publicExponent, modulus };
909
+ };
910
+
911
+ // src/modules/login_np.ts
912
+ var RSAKey = rsalib_default.RSAKey;
913
+ function randomString() {
914
+ const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
915
+ return random.toLowerCase();
916
+ }
917
+ var loginNP = {
918
+ async authn(username, password) {
919
+ var error = "";
920
+ var $ = {
921
+ "isAsync": true,
922
+ "enpassword": "",
923
+ "captcha": "",
924
+ "appType": "0",
925
+ "loginID": "",
926
+ "relayState": "",
927
+ "sourceID": "220029",
928
+ "imgcodeType": "1",
929
+ "fingerPrint": "",
930
+ "fingerPrintDetail": ""
931
+ };
932
+ const p = await getPublicKey();
933
+ const { publicExponent, modulus } = p || {};
934
+ if (!modulus || !publicExponent) {
935
+ error = "\u83B7\u53D6\u516C\u94A5\u5931\u8D25";
936
+ return { error };
937
+ }
938
+ var rsa2 = new RSAKey();
939
+ rsa2.setPublic(modulus, publicExponent);
940
+ const rsa_pwd = rsa2.encrypt(password);
941
+ const rsa_username = rsa2.encrypt(username);
942
+ const fakeFingerprint = randomString();
943
+ $.fingerPrint = fakeFingerprint;
944
+ $.fingerPrintDetail = fakeFingerprint;
945
+ $.enpassword = rsa_pwd;
946
+ $.loginID = rsa_username;
947
+ const form = new URLSearchParams();
948
+ for (const [key, value] of Object.entries($)) {
949
+ form.append(key, String(value));
950
+ }
951
+ const res = await fetch(
952
+ `https://passport.migu.cn/authn`,
953
+ {
954
+ method: "POST",
955
+ headers: {
956
+ "Host": "passport.migu.cn"
957
+ },
958
+ body: form
959
+ }
960
+ );
961
+ if (!res.ok) return { error: ["\u8BF7\u6C42\u767B\u5F55\u5931\u8D25"] };
962
+ const body = await res.json();
963
+ return body;
964
+ }
965
+ };
966
+
967
+ // src/modules/passport_checkToken.ts
968
+ var checkToken = async (token = "") => {
969
+ return await h5fetch(
970
+ `https://c.musicapp.migu.cn/mgateway/api/checkPacMtoken`,
971
+ {
972
+ headers: {
973
+ "pacmtoken": token
974
+ }
975
+ }
976
+ );
977
+ };
978
+
979
+ // src/utils/setCookie.ts
980
+ var parseSetCookies = (headers) => {
981
+ if (typeof headers.getSetCookie === "function") {
982
+ return headers.getSetCookie() || [];
983
+ }
984
+ const setCookieHeader = headers.get("set-cookie");
985
+ if (!setCookieHeader) {
986
+ return [];
987
+ }
988
+ return setCookieHeader.split(",").map((c) => c.trim());
989
+ };
990
+ var getCookieValue = (cookies, key) => {
991
+ for (const item of cookies) {
992
+ const prefix = `${key}=`;
993
+ if (item.includes(prefix)) {
994
+ const mainPart = item.split(";")[0];
995
+ return mainPart.split("=")[1] || "";
996
+ }
997
+ }
998
+ return "";
999
+ };
1000
+ var getSetCookieValue = (headers, key) => {
1001
+ const cookies = parseSetCookies(headers);
1002
+ return getCookieValue(cookies, key);
1003
+ };
1004
+
1005
+ // src/modules/passport_pacmToken.ts
1006
+ var getPacmToken = async (token = "", type = "2", sourceId = "220029", activityId = "MUSIC-WWW") => {
1007
+ const res = await fetch(
1008
+ `https://c.musicapp.migu.cn/user/h5/token-validate/v3.0?token=${token}&type=${type}&sourceId=${sourceId}&activityId=${activityId}`,
1009
+ {
1010
+ headers: {
1011
+ "Cookie": "idmpauth=true@passport.migu.cn",
1012
+ "Origin": "https://music.migu.cn",
1013
+ "Pragma": "no-cache",
1014
+ "Referer": "https://music.migu.cn/"
1015
+ },
1016
+ method: "GET"
1017
+ }
1018
+ );
1019
+ const cookie = parseSetCookies(res.headers);
1020
+ const pacmToken = getCookieValue(cookie, "pacmtoken");
1021
+ const body = await res.json();
1022
+ return { pacmToken, cookie, body };
1023
+ };
1024
+
1025
+ // src/modules/ticket.ts
1026
+ var getTicketInfo = async (page = 1, pageCount = 20) => {
1027
+ return await h5fetch(`https://app.c.nf.migu.cn/MIGUM3.0/v1.0/ticket/home/ticket?pageNum=${page}&pageCount=${pageCount}`);
1028
+ };
1029
+
1030
+ // src/modules/user_badge.ts
1031
+ var getUserBadge = async (pacmtoken) => {
1032
+ const res = await fetch(
1033
+ `https://app.c.nf.migu.cn/pc/open/api/member/icon/v1.0`,
1034
+ {
1035
+ method: "GET",
1036
+ headers: {
1037
+ "Cookie": `pacmtoken=${pacmtoken}`,
1038
+ "Referer": "https://music.migu.cn/",
1039
+ "channel": "014X031",
1040
+ "timestamp": Date.now().toString()
1041
+ }
1042
+ }
1043
+ );
1044
+ const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
1045
+ const data = await res.json();
1046
+ return { data, pacmtoken: newPacmToken };
1047
+ };
1048
+
1049
+ // src/modules/user_queryInfo.ts
1050
+ var queryUserInfo = async (pacmtoken) => {
1051
+ const res = await fetch(
1052
+ `https://app.c.nf.migu.cn/pc/user/h5/queryUserInfo/v1.0`,
1053
+ {
1054
+ method: "GET",
1055
+ headers: {
1056
+ "Cookie": `pacmtoken=${pacmtoken}`,
1057
+ "channel": "014X031",
1058
+ "Referer": `https://music.migu.cn/`
1059
+ //可不用
1060
+ }
1061
+ }
1062
+ );
1063
+ const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
1064
+ const data = await res.json();
1065
+ return { data, pacmtoken: newPacmToken };
1066
+ };
1067
+
1068
+ // src/modules/user_homePage.ts
1069
+ var getUserHomePage = async (pacmtoken) => {
1070
+ const res = await fetch(
1071
+ `https://app.c.nf.migu.cn/pc/user/home-page/v2.0`,
1072
+ {
1073
+ method: "GET",
1074
+ headers: {
1075
+ "Cookie": `pacmtoken=${pacmtoken}`
1076
+ //"channel": "014X031",
1077
+ //"Referer": `https://music.migu.cn/`
1078
+ }
1079
+ }
1080
+ );
1081
+ const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
1082
+ const data = await res.json();
1083
+ return { data, pacmtoken: newPacmToken };
1084
+ };
1085
+
1086
+ // src/modules/user_recom_today.ts
1087
+ var getTodayRecommend = async (pacmtoken) => {
1088
+ const res = await fetch(
1089
+ `https://app.c.nf.migu.cn/pc/v1.0/template/todayRecommendList/release?actionId=1&index=1&templateVersion=5`,
1090
+ {
1091
+ method: "GET",
1092
+ headers: {
1093
+ "Cookie": `pacmtoken=${pacmtoken}`
1094
+ //"channel": "014X031",
1095
+ //"Referer": `https://music.migu.cn/`
1096
+ }
1097
+ }
1098
+ );
1099
+ const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
1100
+ const data = await res.json();
1101
+ return { data, pacmtoken: newPacmToken };
1102
+ };
1103
+
374
1104
  // src/index.ts
375
1105
  function createClient() {
376
1106
  return modules_exports;
377
1107
  }
378
1108
  export {
379
1109
  checkCanListen,
1110
+ checkToken,
380
1111
  createClient,
381
1112
  getAlbumInfo,
382
1113
  getAlbumSong,
383
1114
  getComment,
1115
+ getMvHls,
1116
+ getMvInfo,
384
1117
  getOpNum,
1118
+ getPacmToken,
385
1119
  getPlaylistInfo,
386
1120
  getPlaylistSong,
1121
+ getRadioRecommend,
387
1122
  getRankIndex,
388
1123
  getRankInfo,
389
1124
  getRecommendPlaylist,
390
- getRecommendSong,
391
1125
  getResourceInfo,
1126
+ getSceneRecommend,
392
1127
  getSearchDefault,
393
1128
  getSearchHot,
394
1129
  getSearchSingerTab,
@@ -396,11 +1131,17 @@ export {
396
1131
  getSingerAlbum,
397
1132
  getSingerIndex,
398
1133
  getSingerSong,
1134
+ getTicketInfo,
1135
+ getTodayRecommend,
399
1136
  getUrlH5V24,
400
1137
  getUrlV1,
401
1138
  getUrlV2,
1139
+ getUserBadge,
1140
+ getUserHomePage,
402
1141
  getVersion,
1142
+ loginNP,
403
1143
  modules_exports as modules,
1144
+ queryUserInfo,
404
1145
  searchAlbum,
405
1146
  searchConcert,
406
1147
  searchRbt,