migu-api-enhanced 2.14.0 → 2.19.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
@@ -34,9 +34,11 @@ __export(index_exports, {
34
34
  RSAKey: () => RSAKey,
35
35
  URLParams: () => URLParams,
36
36
  YDRZ: () => YDRZ,
37
+ addFollower: () => addFollower,
37
38
  addSongToMyList: () => addSongToMyList,
38
39
  addUserCollect: () => addUserCollect,
39
40
  addUserMyList: () => addUserMyList,
41
+ changeQuality: () => changeQuality,
40
42
  checkCanListen: () => checkCanListen,
41
43
  checkToken: () => checkToken,
42
44
  createClient: () => createClient,
@@ -44,6 +46,7 @@ __export(index_exports, {
44
46
  editUserMyList: () => editUserMyList,
45
47
  getAlbumInfo: () => getAlbumInfo,
46
48
  getAlbumSong: () => getAlbumSong,
49
+ getCloudUrl: () => getCloudUrl,
47
50
  getColumnInfo: () => getColumnInfo,
48
51
  getComment: () => getComment,
49
52
  getConcertComment: () => getConcertComment,
@@ -51,7 +54,12 @@ __export(index_exports, {
51
54
  getConcertInfo: () => getConcertInfo,
52
55
  getConcertRecommendMv: () => getConcertRecommendMv,
53
56
  getConcertUrl: () => getConcertUrl,
57
+ getDLUrlV1: () => getDLUrlV1,
54
58
  getDeviceId: () => getDeviceId,
59
+ getFollowerList: () => getFollowerList,
60
+ getFollowingList: () => getFollowingList,
61
+ getFollowingVra: () => getFollowingVra,
62
+ getListenRank: () => getListenRank,
55
63
  getLyric: () => getLyric,
56
64
  getMVRecommend: () => getMVRecommend,
57
65
  getMvBySong: () => getMvBySong,
@@ -64,10 +72,13 @@ __export(index_exports, {
64
72
  getNinanSong: () => getNinanSong,
65
73
  getOpNum: () => getOpNum,
66
74
  getPacmToken: () => getPacmToken,
75
+ getPageInfo: () => getPageInfo,
76
+ getPageTab: () => getPageTab,
67
77
  getPlaylistInfo: () => getPlaylistInfo,
68
78
  getPlaylistSong: () => getPlaylistSong,
69
79
  getPlaylistSquarePage: () => getPlaylistSquarePage,
70
80
  getPublicKey: () => getPublicKey,
81
+ getQuality: () => getQuality,
71
82
  getRadioRecommend: () => getRadioRecommend,
72
83
  getRadioRecommendAll: () => getRadioRecommendAll,
73
84
  getRadioSong: () => getRadioSong,
@@ -75,8 +86,10 @@ __export(index_exports, {
75
86
  getRankInfo: () => getRankInfo,
76
87
  getRecommendPlaylist: () => getRecommendPlaylist,
77
88
  getRedirectUrl: () => getRedirectUrl,
89
+ getResourceId: () => getResourceId,
78
90
  getResourceInfo: () => getResourceInfo,
79
91
  getSVideoInfo: () => getSVideoInfo,
92
+ getSVideoRecommend: () => getSVideoRecommend,
80
93
  getSVideoSearchSuggest: () => getSVideoSearchSuggest,
81
94
  getSVideoUrl: () => getSVideoUrl,
82
95
  getSVideoUserContent: () => getSVideoUserContent,
@@ -94,25 +107,33 @@ __export(index_exports, {
94
107
  getTicketInfo: () => getTicketInfo,
95
108
  getTodayRecommend: () => getTodayRecommend,
96
109
  getUrlH5V24: () => getUrlH5V24,
110
+ getUrlM2: () => getUrlM2,
97
111
  getUrlV1: () => getUrlV1,
98
112
  getUrlV2: () => getUrlV2,
113
+ getUserAudioBook: () => getUserAudioBook,
99
114
  getUserBadge: () => getUserBadge,
100
115
  getUserCollectList: () => getUserCollectList,
116
+ getUserHeader: () => getUserHeader,
101
117
  getUserHomePage: () => getUserHomePage,
102
118
  getUserMyList: () => getUserMyList,
119
+ getUserSongPage: () => getUserSongPage,
103
120
  getVersion: () => getVersion,
104
121
  getVipPlaylist: () => getVipPlaylist,
105
122
  getVrbtOpNum: () => getVrbtOpNum,
106
123
  getVrbtUrl: () => getVrbtUrl,
107
124
  isFollowAuthor: () => isFollowAuthor,
125
+ isQuality: () => isQuality,
108
126
  likeSong: () => likeSong,
109
127
  loginNP: () => loginNP,
110
128
  loginOneClick: () => loginOneClick,
111
129
  loginPhone: () => loginPhone,
112
130
  loginSim: () => loginSim,
131
+ logout: () => logout,
113
132
  matchPlaylist: () => matchPlaylist,
114
133
  modules: () => modules_exports,
134
+ qualityList: () => qualityList,
115
135
  queryUserInfo: () => queryUserInfo,
136
+ removeFollower: () => removeFollower,
116
137
  removeSongFromMyList: () => removeSongFromMyList,
117
138
  removeUserCollect: () => removeUserCollect,
118
139
  removeUserMyList: () => removeUserMyList,
@@ -126,7 +147,11 @@ __export(index_exports, {
126
147
  searchSong: () => searchSong,
127
148
  searchSuggest: () => searchSuggest,
128
149
  searchTicket: () => searchTicket,
129
- signNinan: () => signNinan
150
+ shareCommon: () => shareCommon,
151
+ shareVideo: () => shareVideo,
152
+ signNinan: () => signNinan,
153
+ toneFormat: () => toneFormat,
154
+ toneUrl: () => toneUrl
130
155
  });
131
156
  module.exports = __toCommonJS(index_exports);
132
157
 
@@ -134,6 +159,7 @@ module.exports = __toCommonJS(index_exports);
134
159
  var modules_exports = {};
135
160
  __export(modules_exports, {
136
161
  YDRZ: () => YDRZ,
162
+ addFollower: () => addFollower,
137
163
  addSongToMyList: () => addSongToMyList,
138
164
  addUserCollect: () => addUserCollect,
139
165
  addUserMyList: () => addUserMyList,
@@ -143,6 +169,7 @@ __export(modules_exports, {
143
169
  editUserMyList: () => editUserMyList,
144
170
  getAlbumInfo: () => getAlbumInfo,
145
171
  getAlbumSong: () => getAlbumSong,
172
+ getCloudUrl: () => getCloudUrl,
146
173
  getColumnInfo: () => getColumnInfo,
147
174
  getComment: () => getComment,
148
175
  getConcertComment: () => getConcertComment,
@@ -150,6 +177,11 @@ __export(modules_exports, {
150
177
  getConcertInfo: () => getConcertInfo,
151
178
  getConcertRecommendMv: () => getConcertRecommendMv,
152
179
  getConcertUrl: () => getConcertUrl,
180
+ getDLUrlV1: () => getDLUrlV1,
181
+ getFollowerList: () => getFollowerList,
182
+ getFollowingList: () => getFollowingList,
183
+ getFollowingVra: () => getFollowingVra,
184
+ getListenRank: () => getListenRank,
153
185
  getLyric: () => getLyric,
154
186
  getMVRecommend: () => getMVRecommend,
155
187
  getMvBySong: () => getMvBySong,
@@ -162,6 +194,8 @@ __export(modules_exports, {
162
194
  getNinanSong: () => getNinanSong,
163
195
  getOpNum: () => getOpNum,
164
196
  getPacmToken: () => getPacmToken,
197
+ getPageInfo: () => getPageInfo,
198
+ getPageTab: () => getPageTab,
165
199
  getPlaylistInfo: () => getPlaylistInfo,
166
200
  getPlaylistSong: () => getPlaylistSong,
167
201
  getPlaylistSquarePage: () => getPlaylistSquarePage,
@@ -174,6 +208,7 @@ __export(modules_exports, {
174
208
  getRedirectUrl: () => getRedirectUrl,
175
209
  getResourceInfo: () => getResourceInfo,
176
210
  getSVideoInfo: () => getSVideoInfo,
211
+ getSVideoRecommend: () => getSVideoRecommend,
177
212
  getSVideoSearchSuggest: () => getSVideoSearchSuggest,
178
213
  getSVideoUrl: () => getSVideoUrl,
179
214
  getSVideoUserContent: () => getSVideoUserContent,
@@ -191,12 +226,16 @@ __export(modules_exports, {
191
226
  getTicketInfo: () => getTicketInfo,
192
227
  getTodayRecommend: () => getTodayRecommend,
193
228
  getUrlH5V24: () => getUrlH5V24,
229
+ getUrlM2: () => getUrlM2,
194
230
  getUrlV1: () => getUrlV1,
195
231
  getUrlV2: () => getUrlV2,
232
+ getUserAudioBook: () => getUserAudioBook,
196
233
  getUserBadge: () => getUserBadge,
197
234
  getUserCollectList: () => getUserCollectList,
235
+ getUserHeader: () => getUserHeader,
198
236
  getUserHomePage: () => getUserHomePage,
199
237
  getUserMyList: () => getUserMyList,
238
+ getUserSongPage: () => getUserSongPage,
200
239
  getVersion: () => getVersion,
201
240
  getVipPlaylist: () => getVipPlaylist,
202
241
  getVrbtOpNum: () => getVrbtOpNum,
@@ -207,8 +246,10 @@ __export(modules_exports, {
207
246
  loginOneClick: () => loginOneClick,
208
247
  loginPhone: () => loginPhone,
209
248
  loginSim: () => loginSim,
249
+ logout: () => logout,
210
250
  matchPlaylist: () => matchPlaylist,
211
251
  queryUserInfo: () => queryUserInfo,
252
+ removeFollower: () => removeFollower,
212
253
  removeSongFromMyList: () => removeSongFromMyList,
213
254
  removeUserCollect: () => removeUserCollect,
214
255
  removeUserMyList: () => removeUserMyList,
@@ -222,6 +263,8 @@ __export(modules_exports, {
222
263
  searchSong: () => searchSong,
223
264
  searchSuggest: () => searchSuggest,
224
265
  searchTicket: () => searchTicket,
266
+ shareCommon: () => shareCommon,
267
+ shareVideo: () => shareVideo,
225
268
  signNinan: () => signNinan
226
269
  });
227
270
 
@@ -427,16 +470,16 @@ var getRecommendPlaylist = async () => {
427
470
 
428
471
  // src/utils/deviceID.ts
429
472
  function getDeviceId(a, b) {
430
- var c, d = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""), e = [];
473
+ var c, d = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""), e2 = [];
431
474
  if (b = b || d.length, a)
432
475
  for (c = 0; a > c; c++)
433
- e[c] = d[0 | Math.random() * b];
476
+ e2[c] = d[0 | Math.random() * b];
434
477
  else {
435
478
  var f;
436
- for (e[8] = e[13] = e[18] = e[23] = "-", e[14] = "4", c = 0; 36 > c; c++)
437
- e[c] || (f = 0 | 16 * Math.random(), e[c] = d[19 == c ? 3 & f | 8 : f]);
479
+ for (e2[8] = e2[13] = e2[18] = e2[23] = "-", e2[14] = "4", c = 0; 36 > c; c++)
480
+ e2[c] || (f = 0 | 16 * Math.random(), e2[c] = d[19 == c ? 3 & f | 8 : f]);
438
481
  }
439
- return e.join("");
482
+ return e2.join("");
440
483
  }
441
484
 
442
485
  // src/modules/recommend_song.ts
@@ -556,20 +599,20 @@ var SECURE = "Jk8qzuePiJ1qE3mDYhLQ3T73DtDoAhLP";
556
599
  var aw = 171;
557
600
  var iw = 205;
558
601
  var ow = 1;
559
- function textEncode(e) {
560
- return new TextEncoder().encode(e);
602
+ function textEncode(e2) {
603
+ return new TextEncoder().encode(e2);
561
604
  }
562
- function textDecode(e) {
563
- return new TextDecoder("utf-8").decode(e);
605
+ function textDecode(e2) {
606
+ return new TextDecoder("utf-8").decode(e2);
564
607
  }
565
- function decryptBlob(e, r) {
608
+ function decryptBlob(e2, r) {
566
609
  if (r.length == 0)
567
610
  return null;
568
- var n = e.length;
569
- if (n < 4 || !(e[0] == aw && e[1] == iw) || e[2] != ow)
611
+ var n = e2.length;
612
+ if (n < 4 || !(e2[0] == aw && e2[1] == iw) || e2[2] != ow)
570
613
  return null;
571
- for (var t = e[3], a = textEncode(r), i = a.length, o = new Uint8Array(n - 4), s = 0, c = 4; c < n; c++, s++)
572
- o[s] = e[c] + t - a[s % i];
614
+ for (var t = e2[3], a = textEncode(r), i = a.length, o = new Uint8Array(n - 4), s = 0, c = 4; c < n; c++, s++)
615
+ o[s] = e2[c] + t - a[s % i];
573
616
  return o;
574
617
  }
575
618
  function decryptData(buf) {
@@ -577,7 +620,7 @@ function decryptData(buf) {
577
620
  try {
578
621
  const data = p ? JSON.parse(p) : null;
579
622
  return data;
580
- } catch (e) {
623
+ } catch (e2) {
581
624
  return null;
582
625
  }
583
626
  ;
@@ -585,6 +628,63 @@ function decryptData(buf) {
585
628
 
586
629
  // src/modules/url_h5v2.4.ts
587
630
  var import_axios3 = __toESM(require("axios"), 1);
631
+
632
+ // src/utils/quality.ts
633
+ var qualityList = [
634
+ "PQ",
635
+ "HQ",
636
+ "SQ",
637
+ "ZQ24",
638
+ "ZQ32",
639
+ "Z3D"
640
+ ];
641
+ var e = encodeURI;
642
+ var toneUrl = {
643
+ "PQ": e("\u6807\u6E05\u9AD8\u6E05/MP3_128_16_Stero"),
644
+ "HQ": e("\u6807\u6E05\u9AD8\u6E05/MP3_320_16_Stero"),
645
+ "SQ": e("\u6B4C\u66F2\u4E0B\u8F7D/flac"),
646
+ "ZQ24": e("\u6B4C\u66F2\u4E0B\u8F7D/flac_24bit"),
647
+ "ZQ32": e("\u6B4C\u66F2\u4E0B\u8F7D/wav_32bit"),
648
+ "Z3D": e("\u6B4C\u66F2\u4E0B\u8F7D/wav_3d")
649
+ };
650
+ var toneUrlList = Object.entries(toneUrl);
651
+ var toneFormat = {
652
+ "PQ": ".mp3",
653
+ "HQ": ".mp3",
654
+ "SQ": ".flac",
655
+ "ZQ24": ".flac",
656
+ "ZQ32": ".wav",
657
+ "Z3D": ".wav"
658
+ };
659
+ function isQuality(quality) {
660
+ return qualityList.includes(quality);
661
+ }
662
+ function getQuality(url) {
663
+ let tone = "";
664
+ if (!tone) {
665
+ for (let i = 0; i < toneUrlList.length; i++) {
666
+ const [key, value] = toneUrlList[i];
667
+ if (url.includes(value)) {
668
+ tone = key;
669
+ break;
670
+ }
671
+ }
672
+ }
673
+ return tone;
674
+ }
675
+ function changeQuality(url, quality, originalQuality, splitQuery = true) {
676
+ const originalTone = isQuality(originalQuality) ? originalQuality : getQuality(url);
677
+ if (splitQuery) {
678
+ url = url.split("?")[0];
679
+ }
680
+ if (!isQuality(quality) || !isQuality(originalTone)) {
681
+ return url;
682
+ } else {
683
+ return url.replace(toneUrl[originalTone], toneUrl[quality]).replace(toneFormat[originalTone], toneFormat[quality]);
684
+ }
685
+ }
686
+
687
+ // src/modules/url_h5v2.4.ts
588
688
  var getUrlH5V24 = async (contentId, copyrightId, toneFlag = "PQ") => {
589
689
  const headers = {
590
690
  "birth": "h5page",
@@ -594,17 +694,22 @@ var getUrlH5V24 = async (contentId, copyrightId, toneFlag = "PQ") => {
594
694
  "location-info": ""
595
695
  };
596
696
  const res = await import_axios3.default.get(
597
- `https://c.musicapp.migu.cn/strategy/listen-url/h5/v2.4?contentId=${contentId}&copyrightId=${copyrightId}&resourceType=2&netType=01&toneFlag=${toneFlag}&scene=&lowerQualityContentId=${contentId}`,
697
+ `https://c.musicapp.migu.cn/strategy/listen-url/h5/v2.4?contentId=${contentId}&copyrightId=${copyrightId}&resourceType=2&netType=01&toneFlag=PQ&scene=&lowerQualityContentId=${contentId}`,
598
698
  {
599
699
  headers,
600
700
  responseType: "arraybuffer"
601
701
  }
602
702
  );
603
- return await decryptData2(res.data);
703
+ const data = await decryptData2(res.data);
704
+ if (data?.data?.url === "") {
705
+ return { success: false, error: "URL \u4E3A\u7A7A" };
706
+ }
707
+ data.data.url = changeQuality(data.data.url || "", toneFlag, "PQ", true);
708
+ return data;
604
709
  };
605
710
  var SECURE2 = ["Jk8qzuePiJ1qE3mDYhLQ3T73DtDoAhLP"];
606
- function strToUtf8Bytes(e) {
607
- return new TextEncoder().encode(e);
711
+ function strToUtf8Bytes(e2) {
712
+ return new TextEncoder().encode(e2);
608
713
  }
609
714
  function utf8Bytes2str(bytes) {
610
715
  const result = [];
@@ -618,18 +723,18 @@ function utf8Bytes2str(bytes) {
618
723
  }
619
724
  return decodeURIComponent(result.join(""));
620
725
  }
621
- function decode(e, t) {
726
+ function decode(e2, t) {
622
727
  if (0 == t.length)
623
728
  return null;
624
- var n = e.length;
729
+ var n = e2.length;
625
730
  if (n < 4)
626
731
  return null;
627
- if (171 != e[0] || 205 != e[1])
732
+ if (171 != e2[0] || 205 != e2[1])
628
733
  return null;
629
- if (1 != e[2])
734
+ if (1 != e2[2])
630
735
  return null;
631
- for (var r = e[3], o = strToUtf8Bytes(t), a = o.length, i = new Uint8Array(n - 4), s = 0, c = 4; c < n; c++, s++)
632
- i[s] = e[c] + r - o[s % a];
736
+ for (var r = e2[3], o = strToUtf8Bytes(t), a = o.length, i = new Uint8Array(n - 4), s = 0, c = 4; c < n; c++, s++)
737
+ i[s] = e2[c] + r - o[s % a];
633
738
  return i;
634
739
  }
635
740
  var decryptData2 = (ab) => {
@@ -828,8 +933,8 @@ var getPacmToken = async (token = "", type = "2", sourceId = "220029", activityI
828
933
  };
829
934
 
830
935
  // src/modules/ticket.ts
831
- var getTicketInfo = async (page = 1, pageCount = 20) => {
832
- return await h5fetch(`https://app.c.nf.migu.cn/MIGUM3.0/v1.0/ticket/home/ticket?pageNum=${page}&pageCount=${pageCount}`);
936
+ var getTicketInfo = async (page = 1, size = 20) => {
937
+ return await h5fetch(`https://app.c.nf.migu.cn/MIGUM3.0/v1.0/ticket/home/ticket?pageNum=${page}&pageCount=${size}`);
833
938
  };
834
939
 
835
940
  // src/modules/user_badge.ts
@@ -1119,9 +1224,9 @@ function md5(s) {
1119
1224
  return import_node_crypto2.default.createHash("md5").update(s, "utf-8").digest("hex");
1120
1225
  }
1121
1226
  var genInternetSign = async () => {
1122
- const time = yTime(), e = time, c = "220029", msgId = getDeviceId(), d = msgId;
1227
+ const time = yTime(), e2 = time, c = "220029", msgId = getDeviceId(), d = msgId;
1123
1228
  const preSign = YDRZ.getSign("300012033963", "1.2"), b = preSign;
1124
- let key = "interfacename=genInternetSign&sourceid=" + c + "&systemtime=" + e + "&msgid=" + d + "&preSign=" + b;
1229
+ let key = "interfacename=genInternetSign&sourceid=" + c + "&systemtime=" + e2 + "&msgid=" + d + "&preSign=" + b;
1125
1230
  key = encodeURIComponent(key);
1126
1231
  const signature = md5(key);
1127
1232
  const url = `https://passport.migu.cn/api/genInternetSign?preSign=${preSign}&msgid=${msgId}&systemtime=${time}&sourceid=220029&signature=${signature}`;
@@ -1385,19 +1490,70 @@ var getLyric = async (contentId) => {
1385
1490
  };
1386
1491
 
1387
1492
  // src/modules/user_collect_add.ts
1388
- var addUserCollect = async (pacmtoken, playlistId, title) => {
1389
- title = encodeURIComponent(title);
1390
- const { data, cookies } = await ckfetch(`https://app.c.nf.migu.cn/pc/v1.0/user/add_collection.do?outOPType=03&outResourceName=${title}&outResourceType=2021&outResourceId=${playlistId}`, {
1391
- cookie: { pacmtoken }
1392
- });
1493
+ var addUserCollect = async (pacmtoken, type, contentId, title, userId) => {
1494
+ let jsonParams = {};
1495
+ if (type === "playlist") {
1496
+ jsonParams = {
1497
+ outOPType: "03",
1498
+ outResourceType: "2021",
1499
+ outResourceId: contentId,
1500
+ outResourceName: encodeURIComponent(title || "")
1501
+ };
1502
+ } else if (type === "comment") {
1503
+ jsonParams = {
1504
+ outOPType: "08",
1505
+ outResourceType: "3002",
1506
+ outOwner: userId,
1507
+ outResourceId: contentId,
1508
+ outResourceName: "%E8%AF%84%E8%AE%BA"
1509
+ //=评论
1510
+ };
1511
+ } else if (type === "album") {
1512
+ jsonParams = {
1513
+ outOPType: "03",
1514
+ outResourceType: "2003",
1515
+ outResourceId: contentId,
1516
+ outResourceName: encodeURIComponent(title || "")
1517
+ };
1518
+ } else {
1519
+ return { success: false, err: "\u672A\u77E5type\u7C7B\u578B -playlist\u6216comment\u6216album" };
1520
+ }
1521
+ const { data, cookies } = await ckfetch(
1522
+ `https://app.u.nf.migu.cn/MIGUM2.0/v1.0/user/add_collection.do`,
1523
+ { params: jsonParams, cookie: { pacmtoken } }
1524
+ );
1393
1525
  return { data, newPacmToken: cookies.pacmtoken || "" };
1394
1526
  };
1395
1527
 
1396
1528
  // src/modules/user_collect_remove.ts
1397
- var removeUserCollect = async (pacmtoken, playlistId) => {
1398
- const { data, cookies } = await ckfetch(`https://app.c.nf.migu.cn/pc/v1.0/user/del_collection.do?oPType=03&resourceType=2021&resourceId=${playlistId}`, {
1399
- cookie: { pacmtoken }
1400
- });
1529
+ var removeUserCollect = async (pacmtoken, type, contentId, userId) => {
1530
+ let jsonParams = {};
1531
+ if (type === "playlist") {
1532
+ jsonParams = {
1533
+ OPType: "03",
1534
+ resourceType: "2021",
1535
+ resourceId: contentId
1536
+ };
1537
+ } else if (type === "comment") {
1538
+ jsonParams = {
1539
+ OPType: "08",
1540
+ resourceType: "3002",
1541
+ outOwner: userId,
1542
+ resourceId: contentId
1543
+ };
1544
+ } else if (type === "album") {
1545
+ jsonParams = {
1546
+ OPType: "03",
1547
+ resourceType: "2003",
1548
+ resourceId: contentId
1549
+ };
1550
+ } else {
1551
+ return { success: false, err: "\u672A\u77E5type\u7C7B\u578B -playlist,comment\u6216album" };
1552
+ }
1553
+ const { data, cookies } = await ckfetch(
1554
+ `https://app.u.nf.migu.cn/MIGUM2.0/v1.0/user/del_collection.do`,
1555
+ { params: jsonParams, cookie: { pacmtoken } }
1556
+ );
1401
1557
  return { data, newPacmToken: cookies.pacmtoken || "" };
1402
1558
  };
1403
1559
 
@@ -1626,14 +1782,14 @@ var getRedirectUrl = async (contentId, toneFlag = "PQ") => {
1626
1782
  {
1627
1783
  maxRedirects: 0,
1628
1784
  params: {
1629
- "toneFlag": toneFlag,
1785
+ "toneFlag": "PQ",
1630
1786
  "copyrightId": "0",
1631
1787
  "contentId": contentId,
1632
1788
  "resourceType": "2",
1633
1789
  "channel": "0"
1634
1790
  }
1635
1791
  }
1636
- ).catch((err) => err.response).then((res) => res?.headers?.location?.split("?")[0] ?? "");
1792
+ ).catch((err) => err.response).then((res) => res?.headers?.location?.split("?")[0] ?? "").then((url) => changeQuality(url, toneFlag, "PQ"));
1637
1793
  };
1638
1794
 
1639
1795
  // src/modules/concert_mv.ts
@@ -1685,15 +1841,294 @@ var getVipPlaylist = async (size = 10) => {
1685
1841
  return await h5fetch(`http://app.c.nf.migu.cn/bmw/vip-exclusive/auditions-list/v1.0?pageSize=${size}`);
1686
1842
  };
1687
1843
 
1844
+ // src/modules/user_header.ts
1845
+ var getUserHeader = async (userId) => {
1846
+ return await h5fetch(
1847
+ `https://app.c.nf.migu.cn/user/api/my-page-header/v1.0`,
1848
+ { params: { userId } }
1849
+ );
1850
+ };
1851
+
1852
+ // src/modules/user_songPage.ts
1853
+ var getUserSongPage = async (userId, videoUserId) => {
1854
+ if (!userId && !videoUserId) {
1855
+ return { data: { error: "userId or videoUserId is required" } };
1856
+ }
1857
+ return await h5fetch(
1858
+ `https://app.c.nf.migu.cn/user/api/my-page-music/v1.0`,
1859
+ {
1860
+ params: { userId, videoUserId },
1861
+ headers: { "channel": "0146931" }
1862
+ }
1863
+ );
1864
+ };
1865
+
1866
+ // src/modules/page_view.ts
1867
+ var getPageInfo = async (pageId, sceneId) => {
1868
+ if (!pageId && !sceneId) {
1869
+ return { success: false, data: { error: "pageId or sceneId is required" } };
1870
+ }
1871
+ if (pageId && sceneId) {
1872
+ return { success: false, data: { error: "choose pageId or sceneId to get page info" } };
1873
+ }
1874
+ const base = "https://app.c.nf.migu.cn/bmw";
1875
+ if (pageId) return await h5fetch(`${base}/page-info/v1.0?pageId=${pageId}`);
1876
+ if (sceneId) return await h5fetch(`${base}/page/view/v1.0?columnId=${sceneId}`);
1877
+ };
1878
+
1879
+ // src/modules/page_tab.ts
1880
+ var getPageTab = async () => {
1881
+ return await h5fetch(`https://app.c.nf.migu.cn/bmw/music/nav-bar/v1.0`);
1882
+ };
1883
+
1884
+ // src/modules/svideo_recommend.ts
1885
+ var getSVideoRecommend = async (pacmtoken) => {
1886
+ const { data, cookies } = await ckfetch("https://app.c.nf.migu.cn/resource-dataloader/recommend-video/v2.0", {
1887
+ method: "GET",
1888
+ cookie: { pacmtoken },
1889
+ params: {
1890
+ currentScreen: 1,
1891
+ scene: "home_selected"
1892
+ },
1893
+ headers: { "Content-Type": "application/json" }
1894
+ });
1895
+ return { data, newPacmToken: cookies.pacmtoken || "" };
1896
+ };
1897
+
1898
+ // src/modules/follow_following_vra.ts
1899
+ var getFollowingVra = async (userId, page = 1) => {
1900
+ return await h5fetch(
1901
+ `https://app.c.nf.migu.cn/bmw/page-data/vrbt/follow-videouserlist/v2.0`,
1902
+ { params: {
1903
+ offset: page - 1,
1904
+ templateVersion: 1,
1905
+ uid: userId
1906
+ } }
1907
+ );
1908
+ };
1909
+
1910
+ // src/modules/follow_follower.ts
1911
+ var getFollowerList = async (params) => {
1912
+ if (params.type === "music") return await h5fetch(
1913
+ `https://app.c.nf.migu.cn/MIGUM2.0/v1.0/user/follower.do`,
1914
+ { params: {
1915
+ pageNo: params.page || 1,
1916
+ pageSize: params.size || 20,
1917
+ userId: params.userId
1918
+ } }
1919
+ );
1920
+ if (params.type === "vrbt") {
1921
+ if (!params.userId && !params.videoUserId) return {
1922
+ success: false,
1923
+ error: "userId or videoUserId is required"
1924
+ };
1925
+ return await h5fetch(
1926
+ `https://app.c.nf.migu.cn/user/i/social/fans-list/v1.0`,
1927
+ { params: {
1928
+ userId: params.userId,
1929
+ videoUserId: params.videoUserId
1930
+ } }
1931
+ );
1932
+ }
1933
+ };
1934
+
1935
+ // src/modules/follow_following.ts
1936
+ var getFollowingList = async (userId, type, page = 1, size = 20) => {
1937
+ if (!userId) return { success: false, error: "userId is required" };
1938
+ if (type !== "user" && type !== "singer") return { success: false, error: "type is invalid" };
1939
+ return await h5fetch(
1940
+ `https://app.c.nf.migu.cn/MIGUM2.0/v1.0/user/followingSingers.do`,
1941
+ { params: {
1942
+ "pageNo": page,
1943
+ "pageSize": size,
1944
+ "userId": userId,
1945
+ "userType": type === "singer" ? "1" : "2"
1946
+ } }
1947
+ );
1948
+ };
1949
+
1950
+ // src/modules/follow_add.ts
1951
+ var addFollower = async (pacmtoken, singerId) => {
1952
+ const { data, cookies } = await ckfetch(
1953
+ `https://app.u.nf.migu.cn/user/social/api/add-follow/v1.0`,
1954
+ {
1955
+ params: {
1956
+ "followId": singerId,
1957
+ "type": "1"
1958
+ },
1959
+ cookie: { pacmtoken }
1960
+ }
1961
+ );
1962
+ return { data, newPacmToken: cookies.pacmtoken || "" };
1963
+ };
1964
+
1965
+ // src/modules/follow_remove.ts
1966
+ var removeFollower = async (pacmtoken, singerId) => {
1967
+ const { data, cookies } = await ckfetch(
1968
+ `https://app.u.nf.migu.cn/user/social/api/delete-follow/v1.0?followId=${singerId}`,
1969
+ { cookie: { pacmtoken } }
1970
+ );
1971
+ return { data, newPacmToken: cookies.pacmtoken || "" };
1972
+ };
1973
+
1974
+ // src/modules/passport_logout.ts
1975
+ var logout = async (pacmtoken) => {
1976
+ const { data } = await ckfetch(`https://c.musicapp.migu.cn/mgateway/api/clearPacMtoken`, {
1977
+ cookie: { pacmtoken }
1978
+ });
1979
+ return data;
1980
+ };
1981
+
1982
+ // src/modules/share_video.ts
1983
+ var shareVideo = async (resourceType, contentId, userId) => {
1984
+ return await h5fetch(
1985
+ `https://app.c.nf.migu.cn/resource/share-info/v2.0`,
1986
+ { params: {
1987
+ "appId": "music",
1988
+ contentId,
1989
+ shareType: resourceType,
1990
+ uid: userId || void 0
1991
+ } }
1992
+ );
1993
+ };
1994
+
1995
+ // src/modules/share_common.ts
1996
+ var shareCommon = async (resourceType, contentId, contentName, targetUserName, copyrightId) => {
1997
+ return await h5fetch(
1998
+ `https://app.c.nf.migu.cn/MIGUM2.0/v1.0/content/shareInfo.do`,
1999
+ { params: {
2000
+ "appId": "music",
2001
+ resourceType,
2002
+ contentId,
2003
+ contentName,
2004
+ targetUserName,
2005
+ copyrightId: copyrightId || void 0,
2006
+ specialType: resourceType === "2003" ? "2" : void 0
2007
+ } }
2008
+ );
2009
+ };
2010
+
2011
+ // src/modules/user_audioBook.ts
2012
+ var getUserAudioBook = async (pacmtoken, recentListenNum = 10, recommendNum = 5) => {
2013
+ const { data, cookies } = await ckfetch("https://pd.musicapp.migu.cn/bmw/audio-book/my-audio-book/v1.0", {
2014
+ cookie: { pacmtoken },
2015
+ headers: { "isMock": "00" },
2016
+ params: {
2017
+ "recentListenCount": recentListenNum,
2018
+ "recommendCount": recommendNum
2019
+ }
2020
+ });
2021
+ return { data, newPacmToken: cookies.pacmtoken || "" };
2022
+ };
2023
+
2024
+ // src/modules/user_listenRank.ts
2025
+ var getListenRank = async (pacmtoken, type) => {
2026
+ const { data, cookies } = await ckfetch(`https://app.c.nf.migu.cn//MIGUM3.0/bmw/listen-song/ranking/v1.0`, {
2027
+ method: "POST",
2028
+ cookie: { pacmtoken },
2029
+ body: JSON.stringify({ "type": type === "year" ? 2 : 1 }),
2030
+ headers: { "Content-Type": "application/json" }
2031
+ });
2032
+ return { data, newPacmToken: cookies.pacmtoken || "" };
2033
+ };
2034
+
2035
+ // src/modules/cloud_url.ts
2036
+ var getCloudUrl = async (pacmtoken, contentId, toneFlag = "PQ") => {
2037
+ const { data, cookies } = await ckfetch("https://app.c.nf.migu.cn/MIGUM3.0/strategy/cloud/listen-url/v1.0", {
2038
+ cookie: { pacmtoken },
2039
+ headers: { "channel": "0146931", "version": "7.41.13" },
2040
+ params: {
2041
+ contentId,
2042
+ "formatType": toneFlag,
2043
+ "type": "0"
2044
+ }
2045
+ });
2046
+ return { data, newPacmToken: cookies.pacmtoken || "" };
2047
+ };
2048
+
2049
+ // src/modules/url_dl_v1.ts
2050
+ var getDLUrlV1 = async (songId, toneFlag = "PQ") => {
2051
+ return await h5fetch(
2052
+ `https://app.c.nf.migu.cn/MIGUM2.0/strategy/download-url/by-songid/v1.0`,
2053
+ {
2054
+ headers: { "channel": "0146931", "version": "7.41.13" },
2055
+ params: {
2056
+ "formatType": toneFlag,
2057
+ songId
2058
+ }
2059
+ }
2060
+ );
2061
+ };
2062
+
2063
+ // src/modules/url_m2.ts
2064
+ var getUrlM2 = async (contentId, toneFlag = "PQ", copyrightId, songId, albumId) => {
2065
+ const data = await h5fetch(
2066
+ `https://app.c.nf.migu.cn/MIGUM2.0/v2.1/content/listen-url`,
2067
+ {
2068
+ params: {
2069
+ "netType": "01",
2070
+ "resourceType": "2",
2071
+ contentId,
2072
+ "toneFlag": "PQ",
2073
+ // PQ 默认返回,覆盖处理
2074
+ "copyrightId": copyrightId || void 0,
2075
+ "albumId": albumId || void 0,
2076
+ "songId": songId || void 0
2077
+ },
2078
+ headers: { "channel": "0146832", "version": "7.41.13" }
2079
+ }
2080
+ );
2081
+ if (data?.data?.url === "") {
2082
+ return { success: false, error: "URL \u4E3A\u7A7A" };
2083
+ }
2084
+ data.data.url = changeQuality(data.data.url || "", toneFlag, "PQ", true);
2085
+ return data;
2086
+ };
2087
+
1688
2088
  // src/utils/index.ts
1689
2089
  var utils_exports = {};
1690
2090
  __export(utils_exports, {
1691
2091
  RSAKey: () => RSAKey,
1692
2092
  URLParams: () => URLParams,
2093
+ changeQuality: () => changeQuality,
1693
2094
  getDeviceId: () => getDeviceId,
1694
- getPublicKey: () => getPublicKey
2095
+ getPublicKey: () => getPublicKey,
2096
+ getQuality: () => getQuality,
2097
+ getResourceId: () => getResourceId,
2098
+ isQuality: () => isQuality,
2099
+ qualityList: () => qualityList,
2100
+ toneFormat: () => toneFormat,
2101
+ toneUrl: () => toneUrl
1695
2102
  });
1696
2103
 
2104
+ // src/utils/resourceType.ts
2105
+ var getResourceId = (name) => {
2106
+ name = name.toLowerCase().trim();
2107
+ switch (name) {
2108
+ case "song":
2109
+ return "2";
2110
+ case "album":
2111
+ return "2003";
2112
+ case "singer":
2113
+ case "artist":
2114
+ return "2002";
2115
+ case "playlist":
2116
+ return "2021";
2117
+ case "radio":
2118
+ return "2016";
2119
+ case "comment":
2120
+ return "3002";
2121
+ case "svideo":
2122
+ return "6000";
2123
+ case "mv":
2124
+ return "D";
2125
+ case "vrbt":
2126
+ return "M";
2127
+ default:
2128
+ return "";
2129
+ }
2130
+ };
2131
+
1697
2132
  // src/index.ts
1698
2133
  function createClient() {
1699
2134
  return modules_exports;
@@ -1704,9 +2139,11 @@ function createClient() {
1704
2139
  RSAKey,
1705
2140
  URLParams,
1706
2141
  YDRZ,
2142
+ addFollower,
1707
2143
  addSongToMyList,
1708
2144
  addUserCollect,
1709
2145
  addUserMyList,
2146
+ changeQuality,
1710
2147
  checkCanListen,
1711
2148
  checkToken,
1712
2149
  createClient,
@@ -1714,6 +2151,7 @@ function createClient() {
1714
2151
  editUserMyList,
1715
2152
  getAlbumInfo,
1716
2153
  getAlbumSong,
2154
+ getCloudUrl,
1717
2155
  getColumnInfo,
1718
2156
  getComment,
1719
2157
  getConcertComment,
@@ -1721,7 +2159,12 @@ function createClient() {
1721
2159
  getConcertInfo,
1722
2160
  getConcertRecommendMv,
1723
2161
  getConcertUrl,
2162
+ getDLUrlV1,
1724
2163
  getDeviceId,
2164
+ getFollowerList,
2165
+ getFollowingList,
2166
+ getFollowingVra,
2167
+ getListenRank,
1725
2168
  getLyric,
1726
2169
  getMVRecommend,
1727
2170
  getMvBySong,
@@ -1734,10 +2177,13 @@ function createClient() {
1734
2177
  getNinanSong,
1735
2178
  getOpNum,
1736
2179
  getPacmToken,
2180
+ getPageInfo,
2181
+ getPageTab,
1737
2182
  getPlaylistInfo,
1738
2183
  getPlaylistSong,
1739
2184
  getPlaylistSquarePage,
1740
2185
  getPublicKey,
2186
+ getQuality,
1741
2187
  getRadioRecommend,
1742
2188
  getRadioRecommendAll,
1743
2189
  getRadioSong,
@@ -1745,8 +2191,10 @@ function createClient() {
1745
2191
  getRankInfo,
1746
2192
  getRecommendPlaylist,
1747
2193
  getRedirectUrl,
2194
+ getResourceId,
1748
2195
  getResourceInfo,
1749
2196
  getSVideoInfo,
2197
+ getSVideoRecommend,
1750
2198
  getSVideoSearchSuggest,
1751
2199
  getSVideoUrl,
1752
2200
  getSVideoUserContent,
@@ -1764,25 +2212,33 @@ function createClient() {
1764
2212
  getTicketInfo,
1765
2213
  getTodayRecommend,
1766
2214
  getUrlH5V24,
2215
+ getUrlM2,
1767
2216
  getUrlV1,
1768
2217
  getUrlV2,
2218
+ getUserAudioBook,
1769
2219
  getUserBadge,
1770
2220
  getUserCollectList,
2221
+ getUserHeader,
1771
2222
  getUserHomePage,
1772
2223
  getUserMyList,
2224
+ getUserSongPage,
1773
2225
  getVersion,
1774
2226
  getVipPlaylist,
1775
2227
  getVrbtOpNum,
1776
2228
  getVrbtUrl,
1777
2229
  isFollowAuthor,
2230
+ isQuality,
1778
2231
  likeSong,
1779
2232
  loginNP,
1780
2233
  loginOneClick,
1781
2234
  loginPhone,
1782
2235
  loginSim,
2236
+ logout,
1783
2237
  matchPlaylist,
1784
2238
  modules,
2239
+ qualityList,
1785
2240
  queryUserInfo,
2241
+ removeFollower,
1786
2242
  removeSongFromMyList,
1787
2243
  removeUserCollect,
1788
2244
  removeUserMyList,
@@ -1796,6 +2252,10 @@ function createClient() {
1796
2252
  searchSong,
1797
2253
  searchSuggest,
1798
2254
  searchTicket,
1799
- signNinan
2255
+ shareCommon,
2256
+ shareVideo,
2257
+ signNinan,
2258
+ toneFormat,
2259
+ toneUrl
1800
2260
  });
1801
2261
  //# sourceMappingURL=index.cjs.map