migu-api-enhanced 1.2.4 → 1.2.5

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.d.cts CHANGED
@@ -67,14 +67,20 @@ declare const getUrlH5V24: (contentId: string, copyrightId: string, resourceType
67
67
 
68
68
  declare const getVersion: (channel?: string, version?: string, ua?: string) => Promise<any>;
69
69
 
70
- declare const getMvInfo: (mvIds: string, { needAbsoluteUrl, }: {
71
- needAbsoluteUrl?: boolean | undefined;
72
- }) => Promise<any>;
70
+ declare const getMvInfo: (mvIds: string) => Promise<any>;
73
71
 
74
72
  declare const getMvHls: (mvContentId: string, mvCopyrightId: string, url: string, size: number, format?: string, needHttps?: boolean) => Promise<any>;
75
73
 
76
74
  declare const loginNP: {
77
- authn(username: string, password: string): Promise<any>;
75
+ /**
76
+ * 账号密码登录
77
+ * @param username 用户名
78
+ * @param password 密码
79
+ * @returns 登录成功后的 pacmtoken
80
+ */
81
+ authn(username: string, password: string): Promise<object | {
82
+ error: string;
83
+ }>;
78
84
  };
79
85
 
80
86
  declare const checkToken: (token?: string) => Promise<any>;
@@ -155,11 +161,71 @@ declare const getSingerSimilar: (singerId: string) => Promise<any>;
155
161
  */
156
162
  declare const getSimilarSongRecommend: (contentId?: string) => Promise<any>;
157
163
 
164
+ type LoginOneClickData = {
165
+ version: string;
166
+ appId: string;
167
+ openType: string;
168
+ expandParams: string;
169
+ isTest: boolean;
170
+ sign: string;
171
+ getNetworkType: string;
172
+ getMsisdnMask: string;
173
+ traceId: string;
174
+ msgId: string;
175
+ timestamp: string;
176
+ uuid: string;
177
+ businessType: string;
178
+ userInformations: string;
179
+ };
180
+ /**
181
+ * 调用方实际只需提供这些字段;其余字段由 getTokenInfo 内部补齐。
182
+ */
183
+ type GetTokenInfoInput = Pick<LoginOneClickData, 'version' | 'appId' | 'openType' | 'expandParams' | 'isTest' | 'sign' | 'getNetworkType' | 'getMsisdnMask'>;
184
+ declare const YDRZ: {
185
+ optparams: {
186
+ uuid: string;
187
+ msgId: string;
188
+ traceId: string;
189
+ businessType: string;
190
+ appId: string;
191
+ timestamp: string;
192
+ isimge: boolean;
193
+ expandParams: string;
194
+ userInformations: string;
195
+ CMRequestApi: string;
196
+ };
197
+ randomString(len: number, range?: number): string;
198
+ randomRange(min: number, max: number): number;
199
+ getUA(): string;
200
+ uaE(str: string): string;
201
+ getUserInfo(): string;
202
+ getSign(appID: string, version: string): string;
203
+ getTokenInfo(data: GetTokenInfoInput): Promise<string | undefined>;
204
+ };
205
+ declare const loginOneClick: {
206
+ genInternetSign: () => Promise<string | undefined>;
207
+ getSTToken: (uniToken: string) => Promise<{
208
+ token: string;
209
+ msisdn: string;
210
+ status: string;
211
+ } | {
212
+ error: string;
213
+ }>;
214
+ authn: () => Promise<{
215
+ token: string;
216
+ msisdn: string;
217
+ status: string;
218
+ } | {
219
+ error: string;
220
+ }>;
221
+ };
222
+
158
223
  /**
159
224
  * modules 子目录统一入口
160
225
  * 汇总导出所有 API 函数
161
226
  */
162
227
 
228
+ declare const api_YDRZ: typeof YDRZ;
163
229
  declare const api_checkCanListen: typeof checkCanListen;
164
230
  declare const api_checkToken: typeof checkToken;
165
231
  declare const api_getAlbumInfo: typeof getAlbumInfo;
@@ -197,6 +263,7 @@ declare const api_getUserHomePage: typeof getUserHomePage;
197
263
  declare const api_getUserMyList: typeof getUserMyList;
198
264
  declare const api_getVersion: typeof getVersion;
199
265
  declare const api_loginNP: typeof loginNP;
266
+ declare const api_loginOneClick: typeof loginOneClick;
200
267
  declare const api_loginSim: typeof loginSim;
201
268
  declare const api_queryUserInfo: typeof queryUserInfo;
202
269
  declare const api_searchAlbum: typeof searchAlbum;
@@ -208,7 +275,7 @@ declare const api_searchSuggest: typeof searchSuggest;
208
275
  declare const api_searchTicket: typeof searchTicket;
209
276
  declare const api_searchVideo: typeof searchVideo;
210
277
  declare namespace api {
211
- export { api_checkCanListen as checkCanListen, api_checkToken as checkToken, api_getAlbumInfo as getAlbumInfo, api_getAlbumSong as getAlbumSong, api_getComment as getComment, api_getMvHls as getMvHls, api_getMvInfo as getMvInfo, api_getOpNum as getOpNum, api_getPacmToken as getPacmToken, api_getPlaylistInfo as getPlaylistInfo, api_getPlaylistSong as getPlaylistSong, api_getRadioRecommend as getRadioRecommend, api_getRankIndex as getRankIndex, api_getRankInfo as getRankInfo, api_getRecommendPlaylist as getRecommendPlaylist, api_getResourceInfo as getResourceInfo, api_getSceneRecommend as getSceneRecommend, api_getSearchDefault as getSearchDefault, api_getSearchHot as getSearchHot, api_getSearchSingerTab as getSearchSingerTab, api_getSearchSingerTabList as getSearchSingerTabList, api_getSimilarSongRecommend as getSimilarSongRecommend, api_getSingerAlbum as getSingerAlbum, api_getSingerIndex as getSingerIndex, api_getSingerSimilar as getSingerSimilar, api_getSingerSong as getSingerSong, api_getTicketInfo as getTicketInfo, api_getTodayRecommend as getTodayRecommend, api_getUrlH5V24 as getUrlH5V24, api_getUrlV1 as getUrlV1, api_getUrlV2 as getUrlV2, api_getUserBadge as getUserBadge, api_getUserCollect as getUserCollect, api_getUserHomePage as getUserHomePage, api_getUserMyList as getUserMyList, api_getVersion as getVersion, api_loginNP as loginNP, api_loginSim as loginSim, api_queryUserInfo as queryUserInfo, api_searchAlbum as searchAlbum, api_searchConcert as searchConcert, api_searchRbt as searchRbt, api_searchSinger as searchSinger, api_searchSong as searchSong, api_searchSuggest as searchSuggest, api_searchTicket as searchTicket, api_searchVideo as searchVideo };
278
+ export { api_YDRZ as YDRZ, api_checkCanListen as checkCanListen, api_checkToken as checkToken, api_getAlbumInfo as getAlbumInfo, api_getAlbumSong as getAlbumSong, api_getComment as getComment, api_getMvHls as getMvHls, api_getMvInfo as getMvInfo, api_getOpNum as getOpNum, api_getPacmToken as getPacmToken, api_getPlaylistInfo as getPlaylistInfo, api_getPlaylistSong as getPlaylistSong, api_getRadioRecommend as getRadioRecommend, api_getRankIndex as getRankIndex, api_getRankInfo as getRankInfo, api_getRecommendPlaylist as getRecommendPlaylist, api_getResourceInfo as getResourceInfo, api_getSceneRecommend as getSceneRecommend, api_getSearchDefault as getSearchDefault, api_getSearchHot as getSearchHot, api_getSearchSingerTab as getSearchSingerTab, api_getSearchSingerTabList as getSearchSingerTabList, api_getSimilarSongRecommend as getSimilarSongRecommend, api_getSingerAlbum as getSingerAlbum, api_getSingerIndex as getSingerIndex, api_getSingerSimilar as getSingerSimilar, api_getSingerSong as getSingerSong, api_getTicketInfo as getTicketInfo, api_getTodayRecommend as getTodayRecommend, api_getUrlH5V24 as getUrlH5V24, api_getUrlV1 as getUrlV1, api_getUrlV2 as getUrlV2, api_getUserBadge as getUserBadge, api_getUserCollect as getUserCollect, api_getUserHomePage as getUserHomePage, api_getUserMyList as getUserMyList, api_getVersion as getVersion, api_loginNP as loginNP, api_loginOneClick as loginOneClick, api_loginSim as loginSim, api_queryUserInfo as queryUserInfo, api_searchAlbum as searchAlbum, api_searchConcert as searchConcert, api_searchRbt as searchRbt, api_searchSinger as searchSinger, api_searchSong as searchSong, api_searchSuggest as searchSuggest, api_searchTicket as searchTicket, api_searchVideo as searchVideo };
212
279
  }
213
280
 
214
281
  /**
@@ -225,4 +292,4 @@ declare function createClient(): typeof api;
225
292
  /** 客户端类型 */
226
293
  type MiguClient = ReturnType<typeof createClient>;
227
294
 
228
- export { type MiguClient, checkCanListen, checkToken, createClient, getAlbumInfo, getAlbumSong, getComment, getMvHls, getMvInfo, getOpNum, getPacmToken, getPlaylistInfo, getPlaylistSong, getRadioRecommend, getRankIndex, getRankInfo, getRecommendPlaylist, getResourceInfo, getSceneRecommend, getSearchDefault, getSearchHot, getSearchSingerTab, getSearchSingerTabList, getSimilarSongRecommend, getSingerAlbum, getSingerIndex, getSingerSimilar, getSingerSong, getTicketInfo, getTodayRecommend, getUrlH5V24, getUrlV1, getUrlV2, getUserBadge, getUserCollect, getUserHomePage, getUserMyList, getVersion, loginNP, loginSim, api as modules, queryUserInfo, searchAlbum, searchConcert, searchRbt, searchSinger, searchSong, searchSuggest, searchTicket, searchVideo };
295
+ export { type MiguClient, YDRZ, checkCanListen, checkToken, createClient, getAlbumInfo, getAlbumSong, getComment, getMvHls, getMvInfo, getOpNum, getPacmToken, getPlaylistInfo, getPlaylistSong, getRadioRecommend, getRankIndex, getRankInfo, getRecommendPlaylist, getResourceInfo, getSceneRecommend, getSearchDefault, getSearchHot, getSearchSingerTab, getSearchSingerTabList, getSimilarSongRecommend, getSingerAlbum, getSingerIndex, getSingerSimilar, getSingerSong, getTicketInfo, getTodayRecommend, getUrlH5V24, getUrlV1, getUrlV2, getUserBadge, getUserCollect, getUserHomePage, getUserMyList, getVersion, loginNP, loginOneClick, loginSim, api as modules, queryUserInfo, searchAlbum, searchConcert, searchRbt, searchSinger, searchSong, searchSuggest, searchTicket, searchVideo };
package/dist/index.d.ts CHANGED
@@ -67,14 +67,20 @@ declare const getUrlH5V24: (contentId: string, copyrightId: string, resourceType
67
67
 
68
68
  declare const getVersion: (channel?: string, version?: string, ua?: string) => Promise<any>;
69
69
 
70
- declare const getMvInfo: (mvIds: string, { needAbsoluteUrl, }: {
71
- needAbsoluteUrl?: boolean | undefined;
72
- }) => Promise<any>;
70
+ declare const getMvInfo: (mvIds: string) => Promise<any>;
73
71
 
74
72
  declare const getMvHls: (mvContentId: string, mvCopyrightId: string, url: string, size: number, format?: string, needHttps?: boolean) => Promise<any>;
75
73
 
76
74
  declare const loginNP: {
77
- authn(username: string, password: string): Promise<any>;
75
+ /**
76
+ * 账号密码登录
77
+ * @param username 用户名
78
+ * @param password 密码
79
+ * @returns 登录成功后的 pacmtoken
80
+ */
81
+ authn(username: string, password: string): Promise<object | {
82
+ error: string;
83
+ }>;
78
84
  };
79
85
 
80
86
  declare const checkToken: (token?: string) => Promise<any>;
@@ -155,11 +161,71 @@ declare const getSingerSimilar: (singerId: string) => Promise<any>;
155
161
  */
156
162
  declare const getSimilarSongRecommend: (contentId?: string) => Promise<any>;
157
163
 
164
+ type LoginOneClickData = {
165
+ version: string;
166
+ appId: string;
167
+ openType: string;
168
+ expandParams: string;
169
+ isTest: boolean;
170
+ sign: string;
171
+ getNetworkType: string;
172
+ getMsisdnMask: string;
173
+ traceId: string;
174
+ msgId: string;
175
+ timestamp: string;
176
+ uuid: string;
177
+ businessType: string;
178
+ userInformations: string;
179
+ };
180
+ /**
181
+ * 调用方实际只需提供这些字段;其余字段由 getTokenInfo 内部补齐。
182
+ */
183
+ type GetTokenInfoInput = Pick<LoginOneClickData, 'version' | 'appId' | 'openType' | 'expandParams' | 'isTest' | 'sign' | 'getNetworkType' | 'getMsisdnMask'>;
184
+ declare const YDRZ: {
185
+ optparams: {
186
+ uuid: string;
187
+ msgId: string;
188
+ traceId: string;
189
+ businessType: string;
190
+ appId: string;
191
+ timestamp: string;
192
+ isimge: boolean;
193
+ expandParams: string;
194
+ userInformations: string;
195
+ CMRequestApi: string;
196
+ };
197
+ randomString(len: number, range?: number): string;
198
+ randomRange(min: number, max: number): number;
199
+ getUA(): string;
200
+ uaE(str: string): string;
201
+ getUserInfo(): string;
202
+ getSign(appID: string, version: string): string;
203
+ getTokenInfo(data: GetTokenInfoInput): Promise<string | undefined>;
204
+ };
205
+ declare const loginOneClick: {
206
+ genInternetSign: () => Promise<string | undefined>;
207
+ getSTToken: (uniToken: string) => Promise<{
208
+ token: string;
209
+ msisdn: string;
210
+ status: string;
211
+ } | {
212
+ error: string;
213
+ }>;
214
+ authn: () => Promise<{
215
+ token: string;
216
+ msisdn: string;
217
+ status: string;
218
+ } | {
219
+ error: string;
220
+ }>;
221
+ };
222
+
158
223
  /**
159
224
  * modules 子目录统一入口
160
225
  * 汇总导出所有 API 函数
161
226
  */
162
227
 
228
+ declare const api_YDRZ: typeof YDRZ;
163
229
  declare const api_checkCanListen: typeof checkCanListen;
164
230
  declare const api_checkToken: typeof checkToken;
165
231
  declare const api_getAlbumInfo: typeof getAlbumInfo;
@@ -197,6 +263,7 @@ declare const api_getUserHomePage: typeof getUserHomePage;
197
263
  declare const api_getUserMyList: typeof getUserMyList;
198
264
  declare const api_getVersion: typeof getVersion;
199
265
  declare const api_loginNP: typeof loginNP;
266
+ declare const api_loginOneClick: typeof loginOneClick;
200
267
  declare const api_loginSim: typeof loginSim;
201
268
  declare const api_queryUserInfo: typeof queryUserInfo;
202
269
  declare const api_searchAlbum: typeof searchAlbum;
@@ -208,7 +275,7 @@ declare const api_searchSuggest: typeof searchSuggest;
208
275
  declare const api_searchTicket: typeof searchTicket;
209
276
  declare const api_searchVideo: typeof searchVideo;
210
277
  declare namespace api {
211
- export { api_checkCanListen as checkCanListen, api_checkToken as checkToken, api_getAlbumInfo as getAlbumInfo, api_getAlbumSong as getAlbumSong, api_getComment as getComment, api_getMvHls as getMvHls, api_getMvInfo as getMvInfo, api_getOpNum as getOpNum, api_getPacmToken as getPacmToken, api_getPlaylistInfo as getPlaylistInfo, api_getPlaylistSong as getPlaylistSong, api_getRadioRecommend as getRadioRecommend, api_getRankIndex as getRankIndex, api_getRankInfo as getRankInfo, api_getRecommendPlaylist as getRecommendPlaylist, api_getResourceInfo as getResourceInfo, api_getSceneRecommend as getSceneRecommend, api_getSearchDefault as getSearchDefault, api_getSearchHot as getSearchHot, api_getSearchSingerTab as getSearchSingerTab, api_getSearchSingerTabList as getSearchSingerTabList, api_getSimilarSongRecommend as getSimilarSongRecommend, api_getSingerAlbum as getSingerAlbum, api_getSingerIndex as getSingerIndex, api_getSingerSimilar as getSingerSimilar, api_getSingerSong as getSingerSong, api_getTicketInfo as getTicketInfo, api_getTodayRecommend as getTodayRecommend, api_getUrlH5V24 as getUrlH5V24, api_getUrlV1 as getUrlV1, api_getUrlV2 as getUrlV2, api_getUserBadge as getUserBadge, api_getUserCollect as getUserCollect, api_getUserHomePage as getUserHomePage, api_getUserMyList as getUserMyList, api_getVersion as getVersion, api_loginNP as loginNP, api_loginSim as loginSim, api_queryUserInfo as queryUserInfo, api_searchAlbum as searchAlbum, api_searchConcert as searchConcert, api_searchRbt as searchRbt, api_searchSinger as searchSinger, api_searchSong as searchSong, api_searchSuggest as searchSuggest, api_searchTicket as searchTicket, api_searchVideo as searchVideo };
278
+ export { api_YDRZ as YDRZ, api_checkCanListen as checkCanListen, api_checkToken as checkToken, api_getAlbumInfo as getAlbumInfo, api_getAlbumSong as getAlbumSong, api_getComment as getComment, api_getMvHls as getMvHls, api_getMvInfo as getMvInfo, api_getOpNum as getOpNum, api_getPacmToken as getPacmToken, api_getPlaylistInfo as getPlaylistInfo, api_getPlaylistSong as getPlaylistSong, api_getRadioRecommend as getRadioRecommend, api_getRankIndex as getRankIndex, api_getRankInfo as getRankInfo, api_getRecommendPlaylist as getRecommendPlaylist, api_getResourceInfo as getResourceInfo, api_getSceneRecommend as getSceneRecommend, api_getSearchDefault as getSearchDefault, api_getSearchHot as getSearchHot, api_getSearchSingerTab as getSearchSingerTab, api_getSearchSingerTabList as getSearchSingerTabList, api_getSimilarSongRecommend as getSimilarSongRecommend, api_getSingerAlbum as getSingerAlbum, api_getSingerIndex as getSingerIndex, api_getSingerSimilar as getSingerSimilar, api_getSingerSong as getSingerSong, api_getTicketInfo as getTicketInfo, api_getTodayRecommend as getTodayRecommend, api_getUrlH5V24 as getUrlH5V24, api_getUrlV1 as getUrlV1, api_getUrlV2 as getUrlV2, api_getUserBadge as getUserBadge, api_getUserCollect as getUserCollect, api_getUserHomePage as getUserHomePage, api_getUserMyList as getUserMyList, api_getVersion as getVersion, api_loginNP as loginNP, api_loginOneClick as loginOneClick, api_loginSim as loginSim, api_queryUserInfo as queryUserInfo, api_searchAlbum as searchAlbum, api_searchConcert as searchConcert, api_searchRbt as searchRbt, api_searchSinger as searchSinger, api_searchSong as searchSong, api_searchSuggest as searchSuggest, api_searchTicket as searchTicket, api_searchVideo as searchVideo };
212
279
  }
213
280
 
214
281
  /**
@@ -225,4 +292,4 @@ declare function createClient(): typeof api;
225
292
  /** 客户端类型 */
226
293
  type MiguClient = ReturnType<typeof createClient>;
227
294
 
228
- export { type MiguClient, checkCanListen, checkToken, createClient, getAlbumInfo, getAlbumSong, getComment, getMvHls, getMvInfo, getOpNum, getPacmToken, getPlaylistInfo, getPlaylistSong, getRadioRecommend, getRankIndex, getRankInfo, getRecommendPlaylist, getResourceInfo, getSceneRecommend, getSearchDefault, getSearchHot, getSearchSingerTab, getSearchSingerTabList, getSimilarSongRecommend, getSingerAlbum, getSingerIndex, getSingerSimilar, getSingerSong, getTicketInfo, getTodayRecommend, getUrlH5V24, getUrlV1, getUrlV2, getUserBadge, getUserCollect, getUserHomePage, getUserMyList, getVersion, loginNP, loginSim, api as modules, queryUserInfo, searchAlbum, searchConcert, searchRbt, searchSinger, searchSong, searchSuggest, searchTicket, searchVideo };
295
+ export { type MiguClient, YDRZ, checkCanListen, checkToken, createClient, getAlbumInfo, getAlbumSong, getComment, getMvHls, getMvInfo, getOpNum, getPacmToken, getPlaylistInfo, getPlaylistSong, getRadioRecommend, getRankIndex, getRankInfo, getRecommendPlaylist, getResourceInfo, getSceneRecommend, getSearchDefault, getSearchHot, getSearchSingerTab, getSearchSingerTabList, getSimilarSongRecommend, getSingerAlbum, getSingerIndex, getSingerSimilar, getSingerSong, getTicketInfo, getTodayRecommend, getUrlH5V24, getUrlV1, getUrlV2, getUserBadge, getUserCollect, getUserHomePage, getUserMyList, getVersion, loginNP, loginOneClick, loginSim, api as modules, queryUserInfo, searchAlbum, searchConcert, searchRbt, searchSinger, searchSong, searchSuggest, searchTicket, searchVideo };
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ var __export = (target, all) => {
7
7
  // src/modules/index.ts
8
8
  var modules_exports = {};
9
9
  __export(modules_exports, {
10
+ YDRZ: () => YDRZ,
10
11
  checkCanListen: () => checkCanListen,
11
12
  checkToken: () => checkToken,
12
13
  getAlbumInfo: () => getAlbumInfo,
@@ -44,6 +45,7 @@ __export(modules_exports, {
44
45
  getUserMyList: () => getUserMyList,
45
46
  getVersion: () => getVersion,
46
47
  loginNP: () => loginNP,
48
+ loginOneClick: () => loginOneClick,
47
49
  loginSim: () => loginSim,
48
50
  queryUserInfo: () => queryUserInfo,
49
51
  searchAlbum: () => searchAlbum,
@@ -189,10 +191,17 @@ var getRecommendPlaylist = async () => {
189
191
  };
190
192
 
191
193
  // src/utils/deviceID.ts
192
- function getDeviceId() {
193
- const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
194
- const a = `${random.substring(0, 8)}-${random.substring(8, 12)}-${random.substring(12, 16)}-${random.substring(16, 20)}-${random.substring(20)}`;
195
- return a.toUpperCase();
194
+ function getDeviceId(a, b) {
195
+ var c, d = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""), e = [];
196
+ if (b = b || d.length, a)
197
+ for (c = 0; a > c; c++)
198
+ e[c] = d[0 | Math.random() * b];
199
+ else {
200
+ var f;
201
+ for (e[8] = e[13] = e[18] = e[23] = "-", e[14] = "4", c = 0; 36 > c; c++)
202
+ e[c] || (f = 0 | 16 * Math.random(), e[c] = d[19 == c ? 3 & f | 8 : f]);
203
+ }
204
+ return e.join("");
196
205
  }
197
206
 
198
207
  // src/modules/recommend_song.ts
@@ -298,7 +307,9 @@ var getUrlV2 = async (contentId, copyrightId, resourceType = "2", pacmtoken = ""
298
307
  "timestamp": timestamp.toString(),
299
308
  "Content-Type": "application/json;charset=UTF-8",
300
309
  "referer": "https://music.migu.cn/",
301
- "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"
310
+ "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",
311
+ "location-data": "30.6698676660,104.1229614820",
312
+ "location-info": ""
302
313
  };
303
314
  const res = await fetch(
304
315
  `https://app.c.nf.migu.cn/strategy/pc/listen/v2.0?contentId=${contentId}&copyrightId=${copyrightId}&scene=&netType=01&resourceType=${resourceType}&toneFlag=PQ`,
@@ -350,7 +361,9 @@ var getUrlH5V24 = async (contentId, copyrightId, resourceType = "2") => {
350
361
  const headers = {
351
362
  "birth": "h5page",
352
363
  "channel": "014X031",
353
- "Referer": "https://y.migu.cn/"
364
+ "Referer": "https://y.migu.cn/",
365
+ "location-data": "30.6698676660,104.1229614820",
366
+ "location-info": ""
354
367
  };
355
368
  const res = await fetch(
356
369
  `https://c.musicapp.migu.cn/strategy/listen-url/h5/v2.4?contentId=${contentId}&copyrightId=${copyrightId}&resourceType=${resourceType}&netType=01&toneFlag=PQ&scene=&lowerQualityContentId=${contentId}`,
@@ -424,30 +437,8 @@ var getVersion = async (channel = "0146921", version = "8.4.0", ua = "Android_mi
424
437
  };
425
438
 
426
439
  // src/modules/mv_info.ts
427
- var getMvInfo = async (mvIds, {
428
- needAbsoluteUrl = false
429
- }) => {
430
- const res = await h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvIds}&resourceType=D&needSimple=01`);
431
- if (!res) return { error: "\u8BF7\u6C42\u5931\u8D25" };
432
- if (res.error) return { error: res.error };
433
- const resource = res.resource || [];
434
- if (resource.length === 0) return { error: "resource\u4E0D\u5B58\u5728" };
435
- if (needAbsoluteUrl) {
436
- resource.forEach((item) => {
437
- if (!item.rateFormats) return;
438
- item.rateFormats.forEach((rateFormat) => {
439
- if (!rateFormat.url) return;
440
- if (!rateFormat.url.startsWith("http") && !rateFormat.url.startsWith("https")) {
441
- if (rateFormat.url[0] === "/" && rateFormat.url[1] !== "/") {
442
- rateFormat.absoluteUrl = `https://freevod.nf.migu.cn${rateFormat.url}`;
443
- }
444
- }
445
- });
446
- });
447
- res.resource = resource;
448
- return res;
449
- }
450
- return res;
440
+ var getMvInfo = async (mvIds) => {
441
+ return h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvIds}&resourceType=D&needSimple=01`);
451
442
  };
452
443
 
453
444
  // src/modules/mv_hls.ts
@@ -912,6 +903,15 @@ var getPublicKey = async () => {
912
903
  return { publicExponent, modulus };
913
904
  };
914
905
 
906
+ // src/utils/URLParams.ts
907
+ function URLParams($) {
908
+ const form = new URLSearchParams();
909
+ for (const [key, value] of Object.entries($)) {
910
+ form.append(key, String(value));
911
+ }
912
+ return form.toString();
913
+ }
914
+
915
915
  // src/modules/login_np.ts
916
916
  var RSAKey = rsalib_default.RSAKey;
917
917
  function randomString() {
@@ -919,8 +919,13 @@ function randomString() {
919
919
  return random.toLowerCase();
920
920
  }
921
921
  var loginNP = {
922
+ /**
923
+ * 账号密码登录
924
+ * @param username 用户名
925
+ * @param password 密码
926
+ * @returns 登录成功后的 pacmtoken
927
+ */
922
928
  async authn(username, password) {
923
- var error = "";
924
929
  var $ = {
925
930
  "isAsync": true,
926
931
  "enpassword": "",
@@ -936,8 +941,7 @@ var loginNP = {
936
941
  const p = await getPublicKey();
937
942
  const { publicExponent, modulus } = p || {};
938
943
  if (!modulus || !publicExponent) {
939
- error = "\u83B7\u53D6\u516C\u94A5\u5931\u8D25";
940
- return { error };
944
+ return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
941
945
  }
942
946
  var rsa2 = new RSAKey();
943
947
  rsa2.setPublic(modulus, publicExponent);
@@ -948,10 +952,7 @@ var loginNP = {
948
952
  $.fingerPrintDetail = fakeFingerprint;
949
953
  $.enpassword = rsa_pwd;
950
954
  $.loginID = rsa_username;
951
- const form = new URLSearchParams();
952
- for (const [key, value] of Object.entries($)) {
953
- form.append(key, String(value));
954
- }
955
+ const form = URLParams($);
955
956
  const res = await fetch(
956
957
  `https://passport.migu.cn/authn`,
957
958
  {
@@ -962,7 +963,7 @@ var loginNP = {
962
963
  body: form
963
964
  }
964
965
  );
965
- if (!res.ok) return { error: ["\u8BF7\u6C42\u767B\u5F55\u5931\u8D25"] };
966
+ if (!res.ok) return { error: "\u8BF7\u6C42\u767B\u5F55\u5931\u8D25" };
966
967
  const body = await res.json();
967
968
  return body;
968
969
  }
@@ -1136,10 +1137,7 @@ var loginSim = {
1136
1137
  $.fingerPrint = fakeFingerprint;
1137
1138
  $.fingerPrintDetail = fakeFingerprint;
1138
1139
  $.encMsisdn = encPhone;
1139
- const form = new URLSearchParams();
1140
- for (const [key, value] of Object.entries($)) {
1141
- form.append(key, String(value));
1142
- }
1140
+ const form = URLParams($);
1143
1141
  const send = await fetch(
1144
1142
  `https://passport.migu.cn/api/simauth/send`,
1145
1143
  {
@@ -1244,11 +1242,203 @@ var getSimilarSongRecommend = async (contentId = "") => {
1244
1242
  );
1245
1243
  };
1246
1244
 
1245
+ // src/modules/login_oneclick.ts
1246
+ import crypto2 from "crypto";
1247
+ var nav = {
1248
+ "platform": "iPhone",
1249
+ "userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Mobile/15E148 Safari/604.1",
1250
+ "appVersion": "5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Mobile/15E148 Safari/604.1",
1251
+ "cookieEnabled": true,
1252
+ "empty": null,
1253
+ "hardwareConcurrency": 6,
1254
+ "language": "zh-CN",
1255
+ "plugins": "",
1256
+ "availWidth": 390,
1257
+ "availHeight": 844,
1258
+ "colorDepth": 24,
1259
+ "timezoneOffset": -480
1260
+ };
1261
+ var YDRZ = {
1262
+ "optparams": {
1263
+ "uuid": "",
1264
+ "msgId": "",
1265
+ "traceId": "",
1266
+ "businessType": "10",
1267
+ "appId": "",
1268
+ "timestamp": yTime(),
1269
+ "isimge": false,
1270
+ "expandParams": "",
1271
+ "userInformations": "",
1272
+ "CMRequestApi": ""
1273
+ },
1274
+ randomString(len, range = 32) {
1275
+ var i, bite = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""), list = [];
1276
+ for (i = 0; i < len; i++)
1277
+ list[i] = bite[0 | Math.random() * range];
1278
+ return list.join("");
1279
+ },
1280
+ randomRange(min, max) {
1281
+ return Math.floor(Math.random() * (min - max) + max);
1282
+ },
1283
+ getUA() {
1284
+ const ua = nav.userAgent, l = [
1285
+ nav.platform,
1286
+ ua,
1287
+ nav.appVersion,
1288
+ nav.cookieEnabled,
1289
+ void 0,
1290
+ nav.hardwareConcurrency,
1291
+ nav.language,
1292
+ nav.plugins,
1293
+ nav.availWidth,
1294
+ nav.availHeight,
1295
+ nav.colorDepth,
1296
+ nav.timezoneOffset
1297
+ ], key = l.join("@@"), finalUA = ua.length > 100 ? ua.substring(0, 100) : ua;
1298
+ return nav.platform + "@@" + finalUA + "@@" + md5(key);
1299
+ },
1300
+ uaE(str) {
1301
+ var b, c, d, r4, r1, r2, r3, result = "", bite = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", i = 0;
1302
+ for (; i < str.length; )
1303
+ r4 = (b = str.charCodeAt(i++)) >> 2, r1 = (3 & b) << 4 | (c = str.charCodeAt(i++)) >> 4, r2 = (15 & c) << 2 | (d = str.charCodeAt(i++)) >> 6, r3 = 63 & d, isNaN(c) ? r2 = r3 = 64 : isNaN(d) && (r3 = 64), result = result + bite.charAt(r4) + bite.charAt(r1) + bite.charAt(r2) + bite.charAt(r3);
1304
+ return result;
1305
+ },
1306
+ getUserInfo() {
1307
+ return encodeURIComponent(this.uaE(this.getUA()));
1308
+ },
1309
+ getSign(appID, version) {
1310
+ const optparams = this.optparams;
1311
+ optparams.uuid = this.randomString(32, 32);
1312
+ optparams.msgId = this.randomString(32, 32);
1313
+ this.optparams = optparams;
1314
+ return appID + optparams.msgId + optparams.timestamp + optparams.uuid + version;
1315
+ },
1316
+ async getTokenInfo(data) {
1317
+ const optparams = this.optparams;
1318
+ const requestData = {
1319
+ "version": data.version,
1320
+ "appId": data.appId,
1321
+ "openType": data.openType,
1322
+ "expandParams": data.expandParams,
1323
+ "isTest": data.isTest,
1324
+ "sign": data.sign,
1325
+ "getNetworkType": data.getNetworkType,
1326
+ "getMsisdnMask": data.getMsisdnMask,
1327
+ "traceId": optparams.uuid,
1328
+ "msgId": optparams.msgId,
1329
+ "timestamp": optparams.timestamp,
1330
+ "uuid": optparams.uuid,
1331
+ "businessType": optparams.businessType,
1332
+ "userInformations": this.getUserInfo()
1333
+ };
1334
+ const res = await fetch(
1335
+ "https://verify.cmpassport.com/h5/getPreMobile",
1336
+ {
1337
+ method: "POST",
1338
+ headers: {
1339
+ "Referer": "https://passport.migu.cn/",
1340
+ "Origin": "https://passport.migu.cn"
1341
+ },
1342
+ body: JSON.stringify(requestData)
1343
+ }
1344
+ );
1345
+ if (!res.ok) return;
1346
+ const json = await res.json(), token = json.body?.token || "";
1347
+ if (!token) return;
1348
+ return token;
1349
+ }
1350
+ };
1351
+ function yTime() {
1352
+ const date = /* @__PURE__ */ new Date(), a = [
1353
+ date.getFullYear(),
1354
+ date.getMonth() + 1,
1355
+ date.getDate(),
1356
+ date.getHours(),
1357
+ date.getMinutes(),
1358
+ date.getSeconds(),
1359
+ date.getMilliseconds()
1360
+ ];
1361
+ const f = a.map((t) => {
1362
+ return t.toString().padStart(2, "0");
1363
+ });
1364
+ f[6] = f[6].toString().padStart(3, "0");
1365
+ return f.join("");
1366
+ }
1367
+ function md5(s) {
1368
+ return crypto2.createHash("md5").update(s, "utf-8").digest("hex");
1369
+ }
1370
+ var genInternetSign = async () => {
1371
+ const time = yTime(), e = time, c = "220029", msgId = getDeviceId(), d = msgId;
1372
+ const preSign = YDRZ.getSign("300012033963", "1.2"), b = preSign;
1373
+ let key = "interfacename=genInternetSign&sourceid=" + c + "&systemtime=" + e + "&msgid=" + d + "&preSign=" + b;
1374
+ key = encodeURIComponent(key);
1375
+ const signature = md5(key);
1376
+ const url = `https://passport.migu.cn/api/genInternetSign?preSign=${preSign}&msgid=${msgId}&systemtime=${time}&sourceid=220029&signature=${signature}`;
1377
+ const res = await fetch(url);
1378
+ if (!res.ok) return void 0;
1379
+ const data = await res.json();
1380
+ if (!data || data.status !== 2e3) return void 0;
1381
+ const rsaSign = data.result?.rsaSign || "";
1382
+ return rsaSign;
1383
+ };
1384
+ var getSTToken = async (uniToken) => {
1385
+ const $ = {
1386
+ "sourceID": "220029",
1387
+ "appType": 0,
1388
+ "relayState": "",
1389
+ "token": uniToken,
1390
+ "userInformation": YDRZ.getUserInfo(),
1391
+ "isFirst": 1
1392
+ };
1393
+ const form = URLParams($);
1394
+ const res = await fetch(
1395
+ "https://passport.migu.cn/authn/uniTokenValidate",
1396
+ {
1397
+ method: "POST",
1398
+ headers: {
1399
+ "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
1400
+ },
1401
+ body: form
1402
+ }
1403
+ );
1404
+ if (!res.ok) return { error: "fetch uni e" };
1405
+ const json = await res.json(), status = json.status?.toString() || "", token = json.result?.token || "", msisdn = json.result?.msisdn || "";
1406
+ if (status !== "2000") return { error: "status e" };
1407
+ return { token, msisdn, status };
1408
+ };
1409
+ var authn = async () => {
1410
+ const rsaSign = await genInternetSign();
1411
+ if (!rsaSign) return { error: "genInternetSign failed" };
1412
+ const uniToken = await YDRZ.getTokenInfo({
1413
+ version: "1.2",
1414
+ appId: "300012033963",
1415
+ sign: rsaSign,
1416
+ openType: "1",
1417
+ expandParams: "",
1418
+ isTest: false,
1419
+ getNetworkType: "",
1420
+ getMsisdnMask: ""
1421
+ });
1422
+ if (!uniToken) return { error: "getTokenInfo failed" };
1423
+ const result = await getSTToken(uniToken);
1424
+ if ("error" in result) return result;
1425
+ const { token, msisdn, status } = result;
1426
+ if (!token) return { error: "no token" };
1427
+ if (!msisdn) return { error: "no msisdn" };
1428
+ return { token, msisdn, status };
1429
+ };
1430
+ var loginOneClick = {
1431
+ genInternetSign,
1432
+ getSTToken,
1433
+ authn
1434
+ };
1435
+
1247
1436
  // src/index.ts
1248
1437
  function createClient() {
1249
1438
  return modules_exports;
1250
1439
  }
1251
1440
  export {
1441
+ YDRZ,
1252
1442
  checkCanListen,
1253
1443
  checkToken,
1254
1444
  createClient,
@@ -1287,6 +1477,7 @@ export {
1287
1477
  getUserMyList,
1288
1478
  getVersion,
1289
1479
  loginNP,
1480
+ loginOneClick,
1290
1481
  loginSim,
1291
1482
  modules_exports as modules,
1292
1483
  queryUserInfo,