migu-api-enhanced 2.3.0 → 2.6.0

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,11 +8,16 @@ var __export = (target, all) => {
8
8
  var modules_exports = {};
9
9
  __export(modules_exports, {
10
10
  YDRZ: () => YDRZ,
11
+ addUserCollect: () => addUserCollect,
12
+ addUserMyList: () => addUserMyList,
11
13
  checkCanListen: () => checkCanListen,
12
14
  checkToken: () => checkToken,
15
+ dislikeSong: () => dislikeSong,
16
+ editUserMyList: () => editUserMyList,
13
17
  getAlbumInfo: () => getAlbumInfo,
14
18
  getAlbumSong: () => getAlbumSong,
15
19
  getComment: () => getComment,
20
+ getLyric: () => getLyric,
16
21
  getMVRecommend: () => getMVRecommend,
17
22
  getMvHls: () => getMvHls,
18
23
  getMvInfo: () => getMvInfo,
@@ -29,6 +34,10 @@ __export(modules_exports, {
29
34
  getRankInfo: () => getRankInfo,
30
35
  getRecommendPlaylist: () => getRecommendPlaylist,
31
36
  getResourceInfo: () => getResourceInfo,
37
+ getSVideoInfo: () => getSVideoInfo,
38
+ getSVideoSearchSuggest: () => getSVideoSearchSuggest,
39
+ getSVideoUrl: () => getSVideoUrl,
40
+ getSVideoUserContent: () => getSVideoUserContent,
32
41
  getSceneRecommend: () => getSceneRecommend,
33
42
  getSearchDefault: () => getSearchDefault,
34
43
  getSearchHot: () => getSearchHot,
@@ -45,24 +54,30 @@ __export(modules_exports, {
45
54
  getUrlV1: () => getUrlV1,
46
55
  getUrlV2: () => getUrlV2,
47
56
  getUserBadge: () => getUserBadge,
48
- getUserCollect: () => getUserCollect,
57
+ getUserCollectList: () => getUserCollectList,
49
58
  getUserHomePage: () => getUserHomePage,
50
59
  getUserMyList: () => getUserMyList,
51
60
  getVersion: () => getVersion,
61
+ getVrbtOpNum: () => getVrbtOpNum,
62
+ getVrbtUrl: () => getVrbtUrl,
63
+ likeSong: () => likeSong,
52
64
  loginNP: () => loginNP,
53
65
  loginOneClick: () => loginOneClick,
54
66
  loginPhone: () => loginPhone,
55
67
  loginSim: () => loginSim,
56
68
  queryUserInfo: () => queryUserInfo,
69
+ removeUserCollect: () => removeUserCollect,
70
+ removeUserMyList: () => removeUserMyList,
57
71
  searchAlbum: () => searchAlbum,
58
72
  searchConcert: () => searchConcert,
59
73
  searchLrc: () => searchLrc,
74
+ searchMv: () => searchMv,
60
75
  searchRbt: () => searchRbt,
76
+ searchSVideo: () => searchSVideo,
61
77
  searchSinger: () => searchSinger,
62
78
  searchSong: () => searchSong,
63
79
  searchSuggest: () => searchSuggest,
64
- searchTicket: () => searchTicket,
65
- searchVideo: () => searchVideo
80
+ searchTicket: () => searchTicket
66
81
  });
67
82
 
68
83
  // src/utils/h5fetch.ts
@@ -127,8 +142,8 @@ var getSearchDefault = async () => {
127
142
  return await h5fetch(`http://app.c.nf.migu.cn/column/search/default-text/v3.0?resourceVersion=2`);
128
143
  };
129
144
 
130
- // src/modules/search_video.ts
131
- var searchVideo = async (text, page = 1, typeOrder = 0) => {
145
+ // src/modules/search_mv.ts
146
+ var searchMv = async (text, page = 1, typeOrder = 0) => {
132
147
  return await h5fetch(`http://app.c.nf.migu.cn/bmw/search/video/v1.0?pageNo=${page}&text=${text}&typeOrder=${typeOrder}`);
133
148
  };
134
149
 
@@ -266,8 +281,10 @@ var getComment = async (resourceId, resourceType = 2, size = 20, hotCommentStart
266
281
  };
267
282
 
268
283
  // src/modules/resourceinfo.ts
269
- var getResourceInfo = async (resourceId, resourceType = 2) => {
270
- return await h5fetch(`https://app.u.nf.migu.cn//MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${resourceId}&resourceType=${resourceType}`);
284
+ var getResourceInfo = async (resourceIds = "", copyrightIds = "", resourceType = 2) => {
285
+ resourceIds = resourceIds.replace(/,/g, "|");
286
+ copyrightIds = copyrightIds.replace(/,/g, "|");
287
+ return await h5fetch(`https://app.u.nf.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${resourceIds}&copyrightId=${copyrightIds}&resourceType=${resourceType}`);
271
288
  };
272
289
 
273
290
  // src/modules/can-listen.ts
@@ -303,34 +320,19 @@ var getUrlV1 = async (contentId, copyrightId, resourceType = "2") => {
303
320
 
304
321
  // src/modules/url_v2.ts
305
322
  import axios2 from "axios";
306
- var getUrlV2 = async (contentId, copyrightId, toneFlag = "PQ", resourceType = "2", pacmtoken = "") => {
323
+ var getUrlV2 = async (contentId, copyrightId, toneFlag = "PQ", pacmtoken = "") => {
307
324
  const deviceId = getDeviceId();
308
- const timestamp = Date.now();
309
325
  const headers = {
310
- "Accept": "application/json, text/plain, */*",
311
- "test": "00",
312
326
  "channel": "014X031",
313
327
  "subchannel": "014X031",
314
- "logId": "cfrom=&appId=h5",
315
- "uid": "",
316
328
  "pacmtoken": pacmtoken,
317
- "appId": "h5",
318
- "platform": "H5",
319
329
  "deviceId": deviceId,
320
- "ua": "Android_migu",
321
- "version": "6.8.8",
322
- "activityId": "MUSIC-WWW",
323
- "birth": "h5page",
324
- "signature": "1",
325
- "timestamp": timestamp.toString(),
326
- "Content-Type": "application/json;charset=UTF-8",
327
330
  "referer": "https://music.migu.cn/",
328
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0",
329
331
  "location-data": "30.6698676660,104.1229614820",
330
332
  "location-info": ""
331
333
  };
332
334
  const res = await axios2.get(
333
- `https://app.c.nf.migu.cn/strategy/pc/listen/v2.0?contentId=${contentId}&copyrightId=${copyrightId}&scene=&netType=01&resourceType=${resourceType}&toneFlag=${toneFlag}`,
335
+ `https://app.c.nf.migu.cn/strategy/pc/listen/v2.0?contentId=${contentId}&copyrightId=${copyrightId}&scene=&netType=01&resourceType=2&toneFlag=${toneFlag}`,
334
336
  {
335
337
  headers,
336
338
  responseType: "arraybuffer"
@@ -371,7 +373,7 @@ function decryptData(buf) {
371
373
 
372
374
  // src/modules/url_h5v2.4.ts
373
375
  import axios3 from "axios";
374
- var getUrlH5V24 = async (contentId, copyrightId, toneFlag = "PQ", resourceType = "2") => {
376
+ var getUrlH5V24 = async (contentId, copyrightId, toneFlag = "PQ") => {
375
377
  const headers = {
376
378
  "birth": "h5page",
377
379
  "channel": "014X031",
@@ -380,7 +382,7 @@ var getUrlH5V24 = async (contentId, copyrightId, toneFlag = "PQ", resourceType =
380
382
  "location-info": ""
381
383
  };
382
384
  const res = await axios3.get(
383
- `https://c.musicapp.migu.cn/strategy/listen-url/h5/v2.4?contentId=${contentId}&copyrightId=${copyrightId}&resourceType=${resourceType}&netType=01&toneFlag=${toneFlag}&scene=&lowerQualityContentId=${contentId}`,
385
+ `https://c.musicapp.migu.cn/strategy/listen-url/h5/v2.4?contentId=${contentId}&copyrightId=${copyrightId}&resourceType=2&netType=01&toneFlag=${toneFlag}&scene=&lowerQualityContentId=${contentId}`,
384
386
  {
385
387
  headers,
386
388
  responseType: "arraybuffer"
@@ -786,9 +788,9 @@ var loginSim = {
786
788
  }
787
789
  };
788
790
 
789
- // src/modules/user_collect.ts
791
+ // src/modules/user_collect_list.ts
790
792
  import axios11 from "axios";
791
- var getUserCollect = async (pacmtoken, page = 1, size = 20) => {
793
+ var getUserCollectList = async (pacmtoken, page = 1, size = 20) => {
792
794
  const res = await axios11.get(`https://app.c.nf.migu.cn/user/h5/user/collection/v1.0?pageNo=${page}&type=1&OPType=03&pageSize=${size}&resourceType=2021`, {
793
795
  headers: {
794
796
  "Cookie": `pacmtoken=${pacmtoken}`
@@ -1142,6 +1144,217 @@ var getRadioRecommendAll = async (pacmtoken = "") => {
1142
1144
  return { data: res.data, newPacmToken };
1143
1145
  };
1144
1146
 
1147
+ // src/modules/svideo_info.ts
1148
+ var getSVideoInfo = async (contentIds) => {
1149
+ const contentIdList = contentIds.split(",");
1150
+ contentIdList.map((item) => {
1151
+ return "6000," + item;
1152
+ }).join("|");
1153
+ return await h5fetch(`https://app.c.nf.migu.cn/resource/video-info/by-id/v1.0?requestParams=${contentIdList}`);
1154
+ };
1155
+
1156
+ // src/modules/svideo_search.ts
1157
+ var searchSVideo = async (text, page = 1) => {
1158
+ return await h5fetch(
1159
+ `https://app.c.nf.migu.cn/bmw/hot-search/search/videos/v1.0?pageIndex=${page}&text=${text}`,
1160
+ {
1161
+ headers: {
1162
+ "deviceid": getDeviceId()
1163
+ }
1164
+ }
1165
+ );
1166
+ };
1167
+
1168
+ // src/modules/svideo_searchSuggest.ts
1169
+ var getSVideoSearchSuggest = async (text) => {
1170
+ return await h5fetch(`https://app.c.nf.migu.cn/resource-dataloader/search-suggest/search/v1.0?text=${text}`);
1171
+ };
1172
+
1173
+ // src/modules/svideo_url.ts
1174
+ var getSVideoUrl = async (contentIds, formatType = "HQ") => {
1175
+ contentIds = contentIds.replace(/,/g, "|");
1176
+ return await h5fetch(`https://app.c.nf.migu.cn/strategy/short-video/play/v1.0?contentIds=${contentIds}&formatType=${formatType}`);
1177
+ };
1178
+
1179
+ // src/modules/svideo_userContent.ts
1180
+ var getSVideoUserContent = async (videoUserId, nextPageId = "") => {
1181
+ return await h5fetch(`https://app.c.nf.migu.cn/user/i/user-content-list/v1.0?nextPageId=${nextPageId}&videoUserId=${videoUserId}`);
1182
+ };
1183
+
1184
+ // src/modules/vrbt_opNum.ts
1185
+ var getVrbtOpNum = async (contentIds) => {
1186
+ return await h5fetch(`https://app.c.nf.migu.cn/resource/vrbt/opnum/v1.0?resourceType=M&contentIds=${contentIds}`);
1187
+ };
1188
+
1189
+ // src/modules/vrbt_url.ts
1190
+ var getVrbtUrl = async (contentIds) => {
1191
+ contentIds = contentIds.replace(/,/g, "|");
1192
+ return await h5fetch(
1193
+ `https://app.c.nf.migu.cn/strategy/vrbt/play/v1.0?contentIds=${contentIds}`,
1194
+ {
1195
+ headers: {
1196
+ "channel": "014X031"
1197
+ }
1198
+ }
1199
+ );
1200
+ };
1201
+
1202
+ // src/modules/lyric.ts
1203
+ import axios16 from "axios";
1204
+ var getLyric = async (contentId) => {
1205
+ if (contentId === "") return { error: "contentId is empty!", success: false };
1206
+ const res = await axios16.get(`https://app.c.nf.migu.cn/resource/song/by-contentids/v2.0?contentId=${contentId}`);
1207
+ const code = res.data.code.toString() || "";
1208
+ const data = res.data.data || [];
1209
+ if (code !== "000000") return {
1210
+ success: false,
1211
+ status: res.status,
1212
+ error: res.data.info || res.data
1213
+ };
1214
+ if (data.length === 0) return { error: "data.length = 0 !", success: false, data };
1215
+ const lrcUrl = data[0].lrcUrl || "";
1216
+ if (lrcUrl === "") return { error: "lrcUrl is empty!", success: false, data };
1217
+ const lrcRes = await axios16.get(lrcUrl);
1218
+ if (lrcRes.status !== 200) return {
1219
+ success: false,
1220
+ status: lrcRes.status,
1221
+ error: "lrcRes.status !== 200 !",
1222
+ data
1223
+ };
1224
+ const lrc = lrcRes.data || "";
1225
+ return {
1226
+ success: true,
1227
+ lrc,
1228
+ lrcUrl
1229
+ };
1230
+ };
1231
+
1232
+ // src/modules/user_collect_add.ts
1233
+ import axios17 from "axios";
1234
+ var addUserCollect = async (pacmtoken, playlistId, title) => {
1235
+ title = encodeURIComponent(title);
1236
+ const res = await axios17.get(
1237
+ `https://app.c.nf.migu.cn/pc/v1.0/user/add_collection.do?outOPType=03&outResourceName=${title}&outResourceType=2021&outResourceId=${playlistId}`,
1238
+ {
1239
+ headers: {
1240
+ "cookie": `pacmtoken=${pacmtoken}`
1241
+ }
1242
+ }
1243
+ );
1244
+ const newPacmToken = getSetCookieValueFromObject(res.headers, "pacmtoken");
1245
+ return { data: res.data, newPacmToken };
1246
+ };
1247
+
1248
+ // src/modules/user_collect_remove.ts
1249
+ import axios18 from "axios";
1250
+ var removeUserCollect = async (pacmtoken, playlistId) => {
1251
+ const res = await axios18.get(
1252
+ `https://app.c.nf.migu.cn/pc/v1.0/user/del_collection.do?oPType=03&resourceType=2021&resourceId=${playlistId}`,
1253
+ {
1254
+ headers: {
1255
+ "cookie": `pacmtoken=${pacmtoken}`
1256
+ }
1257
+ }
1258
+ );
1259
+ const newPacmToken = getSetCookieValueFromObject(res.headers, "pacmtoken");
1260
+ return { data: res.data, newPacmToken };
1261
+ };
1262
+
1263
+ // src/modules/user_like.ts
1264
+ import axios19 from "axios";
1265
+ var likeSong = async (pacmtoken, contentIds) => {
1266
+ const contentIdsList = contentIds.split(",");
1267
+ const res = await axios19.post(
1268
+ `https://app.c.nf.migu.cn/pc/user/api/add-music-list-song/v1.0`,
1269
+ {
1270
+ contentIds: contentIdsList
1271
+ },
1272
+ {
1273
+ headers: {
1274
+ "Cookie": `pacmtoken=${pacmtoken}`
1275
+ }
1276
+ }
1277
+ );
1278
+ const newPacmToken = getSetCookieValueFromObject(res.headers, "pacmtoken");
1279
+ return { data: res.data, newPacmToken };
1280
+ };
1281
+
1282
+ // src/modules/user_dislike.ts
1283
+ import axios20 from "axios";
1284
+ var dislikeSong = async (pacmtoken, contentId) => {
1285
+ const body = {
1286
+ "channel": "23",
1287
+ "contentId": contentId,
1288
+ "songflag": "2"
1289
+ };
1290
+ const res = await axios20.post(
1291
+ `https://app.c.nf.migu.cn/pc/user/h5-import-musiclist/v1.0`,
1292
+ body,
1293
+ {
1294
+ headers: {
1295
+ "Cookie": `pacmtoken=${pacmtoken}`
1296
+ }
1297
+ }
1298
+ );
1299
+ const newPacmToken = getSetCookieValueFromObject(res.headers, "pacmtoken");
1300
+ return { data: res.data, newPacmToken };
1301
+ };
1302
+
1303
+ // src/modules/user_myList_edit.ts
1304
+ import axios21 from "axios";
1305
+ var editUserMyList = async (pacmtoken, title, playlistId) => {
1306
+ const body = {
1307
+ "title": title,
1308
+ "channel": "23",
1309
+ "id": playlistId,
1310
+ "songflag": "0"
1311
+ };
1312
+ const res = await axios21.post(
1313
+ `https://app.c.nf.migu.cn/pc/user/h5-import-musiclist/v1.0`,
1314
+ body,
1315
+ {
1316
+ headers: {
1317
+ "Cookie": `pacmtoken=${pacmtoken}`
1318
+ }
1319
+ }
1320
+ );
1321
+ const newPacmToken = getSetCookieValueFromObject(res.headers, "pacmtoken");
1322
+ return { data: res.data, newPacmToken };
1323
+ };
1324
+
1325
+ // src/modules/user_myList_add.ts
1326
+ import axios22 from "axios";
1327
+ var addUserMyList = async (pacmtoken, title) => {
1328
+ const body = {
1329
+ "title": title,
1330
+ "channel": "23",
1331
+ "type": "self_build"
1332
+ };
1333
+ const res = await axios22.post(
1334
+ `https://app.c.nf.migu.cn/pc/open/api/music-list/add/v2.0`,
1335
+ body,
1336
+ {
1337
+ headers: {
1338
+ "Cookie": `pacmtoken=${pacmtoken}`
1339
+ }
1340
+ }
1341
+ );
1342
+ const newPacmToken = getSetCookieValueFromObject(res.headers, "pacmtoken");
1343
+ return { data: res.data, newPacmToken };
1344
+ };
1345
+
1346
+ // src/modules/user_myList_remove.ts
1347
+ import axios23 from "axios";
1348
+ var removeUserMyList = async (pacmtoken, playlistId) => {
1349
+ const res = await axios23.get(`https://app.c.nf.migu.cn/pc/v1.0/user/deleteMusicList.do?channel=23&id=${playlistId}`, {
1350
+ headers: {
1351
+ "Cookie": `pacmtoken=${pacmtoken}`
1352
+ }
1353
+ });
1354
+ const newPacmToken = getSetCookieValueFromObject(res.headers, "pacmtoken");
1355
+ return { data: res.data, newPacmToken };
1356
+ };
1357
+
1145
1358
  // src/utils/index.ts
1146
1359
  var utils_exports = {};
1147
1360
  __export(utils_exports, {
@@ -1175,13 +1388,18 @@ export {
1175
1388
  RSAKey,
1176
1389
  URLParams,
1177
1390
  YDRZ,
1391
+ addUserCollect,
1392
+ addUserMyList,
1178
1393
  checkCanListen,
1179
1394
  checkToken,
1180
1395
  createClient,
1396
+ dislikeSong,
1397
+ editUserMyList,
1181
1398
  getAlbumInfo,
1182
1399
  getAlbumSong,
1183
1400
  getComment,
1184
1401
  getDeviceId,
1402
+ getLyric,
1185
1403
  getMVRecommend,
1186
1404
  getMvHls,
1187
1405
  getMvInfo,
@@ -1199,6 +1417,10 @@ export {
1199
1417
  getRankInfo,
1200
1418
  getRecommendPlaylist,
1201
1419
  getResourceInfo,
1420
+ getSVideoInfo,
1421
+ getSVideoSearchSuggest,
1422
+ getSVideoUrl,
1423
+ getSVideoUserContent,
1202
1424
  getSceneRecommend,
1203
1425
  getSearchDefault,
1204
1426
  getSearchHot,
@@ -1215,10 +1437,13 @@ export {
1215
1437
  getUrlV1,
1216
1438
  getUrlV2,
1217
1439
  getUserBadge,
1218
- getUserCollect,
1440
+ getUserCollectList,
1219
1441
  getUserHomePage,
1220
1442
  getUserMyList,
1221
1443
  getVersion,
1444
+ getVrbtOpNum,
1445
+ getVrbtUrl,
1446
+ likeSong,
1222
1447
  loginNP,
1223
1448
  loginOneClick,
1224
1449
  loginPhone,
@@ -1226,15 +1451,18 @@ export {
1226
1451
  modules_exports as modules,
1227
1452
  queryUserInfo,
1228
1453
  randomUA,
1454
+ removeUserCollect,
1455
+ removeUserMyList,
1229
1456
  searchAlbum,
1230
1457
  searchConcert,
1231
1458
  searchLrc,
1459
+ searchMv,
1232
1460
  searchRbt,
1461
+ searchSVideo,
1233
1462
  searchSinger,
1234
1463
  searchSong,
1235
1464
  searchSuggest,
1236
1465
  searchTicket,
1237
- searchVideo,
1238
1466
  ua
1239
1467
  };
1240
1468
  //# sourceMappingURL=index.js.map