@ikenxuan/amagi 6.0.0-beta.0 → 6.0.0-beta.2

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/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  ## 安装
9
9
 
10
10
  ```bash
11
- pnpm add @ikenxuan/amagi@alpha
11
+ pnpm add @ikenxuan/amagi@beta
12
12
  ```
13
13
 
14
14
  ## 使用
@@ -1146,9 +1146,20 @@ const DouyinCommentReplyParamsSchema = zod.default.object({
1146
1146
  });
1147
1147
  /** 用户参数验证 */
1148
1148
  const DouyinUserParamsSchema = zod.default.object({
1149
- methodType: zod.default.enum(["userProfile", "userVideoList"], { error: "方法类型必须是指定的枚举值之一" }),
1149
+ methodType: zod.default.literal("userProfile", { error: "方法类型必须是\"userProfile\"" }),
1150
1150
  sec_uid: zod.default.string({ error: "用户ID必须是字符串" }).min(1, { error: "用户ID不能为空" })
1151
1151
  });
1152
+ /** 用户列表参数验证(视频列表、喜欢列表、推荐列表) */
1153
+ const DouyinUserListParamsSchema = zod.default.object({
1154
+ methodType: zod.default.enum([
1155
+ "userVideoList",
1156
+ "userFavoriteList",
1157
+ "userRecommendList"
1158
+ ], { error: "方法类型必须是指定的枚举值之一" }),
1159
+ sec_uid: zod.default.string({ error: "用户ID必须是字符串" }).min(1, { error: "用户ID不能为空" }),
1160
+ number: smartPositiveInteger("获取数量必须是正整数").optional().default(18),
1161
+ max_cursor: zod.default.string({ error: "游标必须是字符串" }).optional()
1162
+ });
1152
1163
  /** 音乐参数验证 */
1153
1164
  const DouyinMusicParamsSchema = zod.default.object({
1154
1165
  methodType: zod.default.literal("musicInfo", { error: "方法类型必须是\"musicInfo\"" }),
@@ -1198,7 +1209,9 @@ const DouyinValidationSchemas = {
1198
1209
  slidesWork: DouyinWorkParamsSchema,
1199
1210
  comments: DouyinCommentParamsSchema,
1200
1211
  userProfile: DouyinUserParamsSchema,
1201
- userVideoList: DouyinUserParamsSchema,
1212
+ userVideoList: DouyinUserListParamsSchema,
1213
+ userFavoriteList: DouyinUserListParamsSchema,
1214
+ userRecommendList: DouyinUserListParamsSchema,
1202
1215
  suggestWords: DouyinHotWordsParamsSchema,
1203
1216
  search: DouyinSearchParamsSchema,
1204
1217
  musicInfo: DouyinMusicParamsSchema,
@@ -1220,6 +1233,8 @@ const DouyinMethodRoutes = {
1220
1233
  commentReplies: "/fetch_video_comment_replies",
1221
1234
  userProfile: "/fetch_user_info",
1222
1235
  userVideoList: "/fetch_user_post_videos",
1236
+ userFavoriteList: "/fetch_user_favorite_list",
1237
+ userRecommendList: "/fetch_user_recommend_list",
1223
1238
  search: "/fetch_search_info",
1224
1239
  suggestWords: "/fetch_suggest_words",
1225
1240
  musicInfo: "/fetch_music_work",
@@ -3445,14 +3460,14 @@ var DouyinAPI = class {
3445
3460
  return `https://www.douyin.com/aweme/v1/web/aweme/post/?${buildQueryString({
3446
3461
  ...this.getBaseParams(),
3447
3462
  sec_user_id: data$1.sec_uid,
3448
- max_cursor: "0",
3463
+ max_cursor: data$1.max_cursor ?? "0",
3449
3464
  locate_query: "false",
3450
3465
  show_live_replay_strategy: "1",
3451
3466
  need_time_list: "1",
3452
3467
  time_list_query: "0",
3453
3468
  whale_cut_token: "",
3454
3469
  cut_version: "1",
3455
- count: "18",
3470
+ count: data$1.number ?? 18,
3456
3471
  publish_video_strategy_type: "2",
3457
3472
  version_code: "170400",
3458
3473
  version_name: "17.4.0",
@@ -3462,6 +3477,72 @@ var DouyinAPI = class {
3462
3477
  webid: "7338423850134226495"
3463
3478
  })}`;
3464
3479
  }
3480
+ /** 获取用户喜欢列表数据 */
3481
+ getUserFavoriteList(data$1) {
3482
+ return `https://www-hj.douyin.com/aweme/v1/web/aweme/favorite/?${buildQueryString({
3483
+ ...this.getBaseParams(),
3484
+ sec_user_id: data$1.sec_uid,
3485
+ max_cursor: data$1.max_cursor ?? "0",
3486
+ min_cursor: "0",
3487
+ whale_cut_token: "",
3488
+ cut_version: "1",
3489
+ count: data$1.number ?? 18,
3490
+ publish_video_strategy_type: "2",
3491
+ update_version_code: "170400",
3492
+ pc_libra_divert: "Windows",
3493
+ support_h265: "1",
3494
+ support_dash: "1",
3495
+ version_code: "170400",
3496
+ version_name: "17.4.0",
3497
+ screen_width: "2328",
3498
+ screen_height: "1310",
3499
+ round_trip_time: "0",
3500
+ webid: "7487210762873685515"
3501
+ })}`;
3502
+ }
3503
+ /** 获取用户推荐列表数据 */
3504
+ getUserRecommendList(data$1) {
3505
+ return `https://www.douyin.com/aweme/v1/web/familiar/recommend/feed/?${buildQueryString({
3506
+ device_platform: "",
3507
+ aid: "6383",
3508
+ channel: "channel_pc_web",
3509
+ sec_user_id: data$1.sec_uid,
3510
+ max_cursor: data$1.max_cursor ?? "0",
3511
+ min_cursor: "0",
3512
+ whale_cut_token: "",
3513
+ count: data$1.number ?? 18,
3514
+ from: "1",
3515
+ update_version_code: "170400",
3516
+ pc_client_type: "1",
3517
+ pc_libra_divert: "Windows",
3518
+ support_h265: "1",
3519
+ support_dash: "1",
3520
+ cpu_core_num: "16",
3521
+ version_code: "170400",
3522
+ version_name: "17.4.0",
3523
+ cookie_enabled: "true",
3524
+ screen_width: "2328",
3525
+ screen_height: "1310",
3526
+ browser_language: "zh-CN",
3527
+ browser_platform: "Win32",
3528
+ browser_name: "Edge",
3529
+ browser_version: this.browserVersion,
3530
+ browser_online: "true",
3531
+ engine_name: "Blink",
3532
+ engine_version: this.browserVersion,
3533
+ os_name: "Windows",
3534
+ os_version: "10",
3535
+ device_memory: "8",
3536
+ platform: "PC",
3537
+ downlink: "10",
3538
+ effective_type: "4g",
3539
+ round_trip_time: "50",
3540
+ webid: "7487210762873685515",
3541
+ msToken: douyinSign.Mstoken(184),
3542
+ verifyFp: fp,
3543
+ fp
3544
+ })}`;
3545
+ }
3465
3546
  /** 获取用户主页信息 */
3466
3547
  getUserProfile(data$1) {
3467
3548
  return `https://www.douyin.com/aweme/v1/web/user/profile/other/?${buildQueryString({
@@ -3880,17 +3961,93 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
3880
3961
  });
3881
3962
  }
3882
3963
  case "userVideoList": {
3883
- const url = douyinApiUrls$1.getUserVideoList({ sec_uid: data$1.sec_uid });
3884
- const customConfig = {
3885
- ...baseRequestConfig,
3886
- headers: {
3887
- ...baseRequestConfig.headers,
3888
- ...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data$1.sec_uid}` }
3889
- }
3890
- };
3891
- return await GlobalGetData$3(data$1.methodType, {
3892
- ...customConfig,
3893
- url: buildSignedUrl(url, signType, userAgent)
3964
+ const urlGenerator = (params) => douyinApiUrls$1.getUserVideoList(params);
3965
+ return await fetchPaginatedData({
3966
+ type: data$1.methodType,
3967
+ apiUrlGenerator: urlGenerator,
3968
+ params: {
3969
+ ...data$1,
3970
+ max_cursor: data$1.max_cursor
3971
+ },
3972
+ maxPageSize: 18,
3973
+ requestConfig: {
3974
+ ...baseRequestConfig,
3975
+ headers: {
3976
+ ...baseRequestConfig.headers,
3977
+ ...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data$1.sec_uid}` }
3978
+ }
3979
+ },
3980
+ signType,
3981
+ extractList: (resp) => resp.aweme_list ?? [],
3982
+ updateParams: (params, resp) => ({
3983
+ ...params,
3984
+ max_cursor: resp.max_cursor?.toString() ?? "0"
3985
+ }),
3986
+ hasMore: (resp) => resp.has_more === 1,
3987
+ formatFinalResponse: (resp, list) => ({
3988
+ ...resp,
3989
+ aweme_list: list
3990
+ })
3991
+ });
3992
+ }
3993
+ case "userFavoriteList": {
3994
+ const urlGenerator = (params) => douyinApiUrls$1.getUserFavoriteList(params);
3995
+ return await fetchPaginatedData({
3996
+ type: data$1.methodType,
3997
+ apiUrlGenerator: urlGenerator,
3998
+ params: {
3999
+ ...data$1,
4000
+ max_cursor: data$1.max_cursor
4001
+ },
4002
+ maxPageSize: 18,
4003
+ requestConfig: {
4004
+ ...baseRequestConfig,
4005
+ headers: {
4006
+ ...baseRequestConfig.headers,
4007
+ ...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data$1.sec_uid}` }
4008
+ }
4009
+ },
4010
+ signType,
4011
+ extractList: (resp) => resp.aweme_list ?? [],
4012
+ updateParams: (params, resp) => ({
4013
+ ...params,
4014
+ max_cursor: resp.max_cursor?.toString() ?? "0"
4015
+ }),
4016
+ hasMore: (resp) => resp.has_more === 1,
4017
+ formatFinalResponse: (resp, list) => ({
4018
+ ...resp,
4019
+ aweme_list: list
4020
+ })
4021
+ });
4022
+ }
4023
+ case "userRecommendList": {
4024
+ const urlGenerator = (params) => douyinApiUrls$1.getUserRecommendList(params);
4025
+ return await fetchPaginatedData({
4026
+ type: data$1.methodType,
4027
+ apiUrlGenerator: urlGenerator,
4028
+ params: {
4029
+ ...data$1,
4030
+ max_cursor: data$1.max_cursor
4031
+ },
4032
+ maxPageSize: 18,
4033
+ requestConfig: {
4034
+ ...baseRequestConfig,
4035
+ headers: {
4036
+ ...baseRequestConfig.headers,
4037
+ ...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data$1.sec_uid}` }
4038
+ }
4039
+ },
4040
+ signType,
4041
+ extractList: (resp) => resp.aweme_list ?? [],
4042
+ updateParams: (params, resp) => ({
4043
+ ...params,
4044
+ max_cursor: resp.max_cursor?.toString() ?? "0"
4045
+ }),
4046
+ hasMore: (resp) => resp.has_more === true,
4047
+ formatFinalResponse: (resp, list) => ({
4048
+ ...resp,
4049
+ aweme_list: list
4050
+ })
3894
4051
  });
3895
4052
  }
3896
4053
  case "suggestWords": {
@@ -4567,13 +4724,15 @@ async function fetchUserProfile$1(options, cookie, requestConfig) {
4567
4724
  * 获取抖音用户视频列表数据
4568
4725
  * @param options - 用户参数
4569
4726
  * @param options.sec_uid - 用户安全 ID
4727
+ * @param options.number - 获取数量,默认 18
4570
4728
  * @param cookie - 抖音 Cookie (可选)
4571
4729
  * @param requestConfig - 请求配置 (可选)
4572
4730
  * @returns 用户视频列表
4573
4731
  * @example
4574
4732
  * ```typescript
4575
- * const result = await fetchUserVideoList({ sec_uid: 'MS4wLjABAAAA...' }, cookie)
4733
+ * const result = await fetchUserVideoList({ sec_uid: 'MS4wLjABAAAA...', number: 30 }, cookie)
4576
4734
  * console.log(result.data.aweme_list) // 视频列表
4735
+ * console.log(result.data.max_cursor) // 下一页游标
4577
4736
  * ```
4578
4737
  */
4579
4738
  async function fetchUserVideoList(options, cookie, requestConfig) {
@@ -4582,6 +4741,48 @@ async function fetchUserVideoList(options, cookie, requestConfig) {
4582
4741
  requestConfig
4583
4742
  });
4584
4743
  }
4744
+ /**
4745
+ * 获取抖音用户喜欢列表数据
4746
+ * @param options - 用户参数
4747
+ * @param options.sec_uid - 用户安全 ID
4748
+ * @param options.number - 获取数量,默认 18
4749
+ * @param cookie - 抖音 Cookie (可选)
4750
+ * @param requestConfig - 请求配置 (可选)
4751
+ * @returns 用户喜欢列表
4752
+ * @example
4753
+ * ```typescript
4754
+ * const result = await fetchUserFavoriteList({ sec_uid: 'MS4wLjABAAAA...', number: 30 }, cookie)
4755
+ * console.log(result.data.aweme_list) // 喜欢的视频列表
4756
+ * console.log(result.data.max_cursor) // 下一页游标
4757
+ * ```
4758
+ */
4759
+ async function fetchUserFavoriteList(options, cookie, requestConfig) {
4760
+ return fetchDouyinInternal("userFavoriteList", options, {
4761
+ cookie,
4762
+ requestConfig
4763
+ });
4764
+ }
4765
+ /**
4766
+ * 获取抖音用户推荐列表数据
4767
+ * @param options - 用户参数
4768
+ * @param options.sec_uid - 用户安全 ID
4769
+ * @param options.number - 获取数量,默认 18
4770
+ * @param cookie - 抖音 Cookie (可选)
4771
+ * @param requestConfig - 请求配置 (可选)
4772
+ * @returns 用户推荐列表
4773
+ * @example
4774
+ * ```typescript
4775
+ * const result = await fetchUserRecommendList({ sec_uid: 'MS4wLjABAAAA...', number: 30 }, cookie)
4776
+ * console.log(result.data.aweme_list) // 推荐的视频列表
4777
+ * console.log(result.data.max_cursor) // 下一页游标
4778
+ * ```
4779
+ */
4780
+ async function fetchUserRecommendList(options, cookie, requestConfig) {
4781
+ return fetchDouyinInternal("userRecommendList", options, {
4782
+ cookie,
4783
+ requestConfig
4784
+ });
4785
+ }
4585
4786
 
4586
4787
  //#endregion
4587
4788
  //#region src/model/fetchers/douyin/video.ts
@@ -4727,6 +4928,8 @@ function createBoundDouyinFetcher(cookie, requestConfig) {
4727
4928
  fetchCommentReplies: (options, reqConfig) => fetchCommentReplies(options, cookie, reqConfig ?? requestConfig),
4728
4929
  fetchUserProfile: (options, reqConfig) => fetchUserProfile$1(options, cookie, reqConfig ?? requestConfig),
4729
4930
  fetchUserVideoList: (options, reqConfig) => fetchUserVideoList(options, cookie, reqConfig ?? requestConfig),
4931
+ fetchUserFavoriteList: (options, reqConfig) => fetchUserFavoriteList(options, cookie, reqConfig ?? requestConfig),
4932
+ fetchUserRecommendList: (options, reqConfig) => fetchUserRecommendList(options, cookie, reqConfig ?? requestConfig),
4730
4933
  searchContent: (options, reqConfig) => searchContent(options, cookie, reqConfig ?? requestConfig),
4731
4934
  fetchSuggestWords: (options, reqConfig) => fetchSuggestWords(options, cookie, reqConfig ?? requestConfig),
4732
4935
  fetchMusicInfo: (options, reqConfig) => fetchMusicInfo(options, cookie, reqConfig ?? requestConfig),
@@ -4764,6 +4967,8 @@ const douyinFetcher = {
4764
4967
  fetchCommentReplies,
4765
4968
  fetchUserProfile: fetchUserProfile$1,
4766
4969
  fetchUserVideoList,
4970
+ fetchUserFavoriteList,
4971
+ fetchUserRecommendList,
4767
4972
  searchContent,
4768
4973
  fetchSuggestWords,
4769
4974
  fetchMusicInfo,
@@ -7803,7 +8008,7 @@ function getApiRoute(platform, methodType) {
7803
8008
  * 构建后使用 __VERSION__,开发环境从 package.json 读取
7804
8009
  */
7805
8010
  const getVersion = () => {
7806
- return "6.0.0-alpha.2";
8011
+ return "6.0.0-beta.1";
7807
8012
  };
7808
8013
  const VERSION = getVersion();
7809
8014
  /**
@@ -7901,6 +8106,7 @@ exports.DouyinMethodToFetcher = DouyinMethodToFetcher;
7901
8106
  exports.DouyinMusicParamsSchema = DouyinMusicParamsSchema;
7902
8107
  exports.DouyinQrcodeParamsSchema = DouyinQrcodeParamsSchema;
7903
8108
  exports.DouyinSearchParamsSchema = DouyinSearchParamsSchema;
8109
+ exports.DouyinUserListParamsSchema = DouyinUserListParamsSchema;
7904
8110
  exports.DouyinUserParamsSchema = DouyinUserParamsSchema;
7905
8111
  exports.DouyinValidationSchemas = DouyinValidationSchemas;
7906
8112
  exports.DouyinWorkParamsSchema = DouyinWorkParamsSchema;