@ikenxuan/amagi 4.4.20-pr117.f85bb30 → 4.5.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.
@@ -385,9 +385,15 @@ var BiLiBiLiAPI = class {
385
385
  return `https://api.bilibili.com/x/space/upstat?mid=${data2.host_mid}`;
386
386
  }
387
387
  };
388
- var bilibiliAPI = new BiLiBiLiAPI();
389
388
  var bilibiliApiUrls = new BiLiBiLiAPI();
390
389
 
390
+ // src/types/NetworksConfigType.ts
391
+ var kuaishouAPIErrorCode = /* @__PURE__ */ ((kuaishouAPIErrorCode2) => {
392
+ kuaishouAPIErrorCode2["COOKIE"] = "INVALID_COOKIE";
393
+ kuaishouAPIErrorCode2["UNKNOWN"] = "UNKNOWN_ERROR" /* UNKNOWN */;
394
+ return kuaishouAPIErrorCode2;
395
+ })(kuaishouAPIErrorCode || {});
396
+
391
397
  // src/platform/bilibili/getdata.ts
392
398
  var defheaders = {
393
399
  accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
@@ -851,727 +857,141 @@ var wbi_sign = async (BASEURL, cookie) => {
851
857
  const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
852
858
  return query;
853
859
  };
854
- function smartNumber(errorMessage, minValue = 1, isInteger = false) {
855
- if (isInteger) {
856
- return z.coerce.number({ required_error: errorMessage }).int(`${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u662F\u6574\u6570\uFF0C\u4E0D\u80FD\u5305\u542B\u5C0F\u6570`).min(minValue, `${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E${minValue}`);
857
- } else {
858
- return z.coerce.number({ required_error: errorMessage }).min(minValue, `${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E${minValue}`);
859
- }
860
- }
861
- var smartPositiveInteger = (errorMessage) => {
862
- return smartNumber(errorMessage, 1, true);
863
- };
864
860
 
865
- // src/validation/douyin.ts
866
- var DouyinWorkParamsSchema = z.object({
867
- methodType: z.enum(["\u89C6\u9891\u4F5C\u54C1\u6570\u636E", "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E", "\u5408\u8F91\u4F5C\u54C1\u6570\u636E", "\u805A\u5408\u89E3\u6790"]),
868
- aweme_id: z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A")
869
- });
870
- var DouyinCommentParamsSchema = z.object({
871
- methodType: z.literal("\u8BC4\u8BBA\u6570\u636E"),
872
- aweme_id: z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A"),
873
- number: smartPositiveInteger("\u8BC4\u8BBA\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(50),
874
- cursor: z.coerce.number().int().min(0).default(0).optional()
875
- });
876
- var DouyinSearchParamsSchema = z.object({
877
- methodType: z.enum(["\u70ED\u70B9\u8BCD\u6570\u636E", "\u641C\u7D22\u6570\u636E"]),
878
- query: z.string({ required_error: "\u641C\u7D22\u8BCD\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u641C\u7D22\u8BCD\u4E0D\u80FD\u4E3A\u7A7A"),
879
- number: smartPositiveInteger("\u641C\u7D22\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(10),
880
- search_id: z.string().optional()
881
- });
882
- var DouyinCommentReplyParamsSchema = z.object({
883
- methodType: z.literal("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E"),
884
- aweme_id: z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A"),
885
- comment_id: z.string({ required_error: "\u8BC4\u8BBAID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u8BC4\u8BBAID\u4E0D\u80FD\u4E3A\u7A7A"),
886
- number: smartPositiveInteger("\u8BC4\u8BBA\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(5),
887
- cursor: z.coerce.number().int().min(0).default(0).optional()
888
- });
889
- var DouyinUserParamsSchema = z.object({
890
- methodType: z.enum(["\u7528\u6237\u4E3B\u9875\u6570\u636E", "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E", "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E"]),
891
- sec_uid: z.string({ required_error: "\u7528\u6237ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u7528\u6237ID\u4E0D\u80FD\u4E3A\u7A7A")
892
- });
893
- var DouyinMusicParamsSchema = z.object({
894
- methodType: z.literal("\u97F3\u4E50\u6570\u636E"),
895
- music_id: z.string({ required_error: "\u97F3\u4E50ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u97F3\u4E50ID\u4E0D\u80FD\u4E3A\u7A7A")
896
- });
897
- var DouyinLiveRoomParamsSchema = z.object({
898
- methodType: z.literal("\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E"),
899
- room_id: z.string({ required_error: "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A"),
900
- web_rid: z.string({ required_error: "\u76F4\u64AD\u95F4\u771F\u5B9E\u623F\u95F4\u53F7\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u76F4\u64AD\u95F4\u771F\u5B9E\u623F\u95F4\u53F7\u4E0D\u80FD\u4E3A\u7A7A")
901
- });
902
- var DouyinQrcodeParamsSchema = z.object({
903
- methodType: z.literal("\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E"),
904
- verify_fp: z.string({ required_error: "fp\u6307\u7EB9\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "fp\u6307\u7EB9\u4E0D\u80FD\u4E3A\u7A7A")
905
- });
906
- var DouyinEmojiListParamsSchema = z.object({
907
- methodType: z.literal("Emoji\u6570\u636E")
908
- });
909
- var DouyinEmojiProParamsSchema = z.object({
910
- methodType: z.literal("\u52A8\u6001\u8868\u60C5\u6570\u636E")
911
- });
912
- var DouyinValidationSchemas2 = {
913
- "\u805A\u5408\u89E3\u6790": DouyinWorkParamsSchema,
914
- "\u89C6\u9891\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
915
- "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
916
- "\u5408\u8F91\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
917
- "\u8BC4\u8BBA\u6570\u636E": DouyinCommentParamsSchema,
918
- "\u7528\u6237\u4E3B\u9875\u6570\u636E": DouyinUserParamsSchema,
919
- "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E": DouyinUserParamsSchema,
920
- "\u70ED\u70B9\u8BCD\u6570\u636E": DouyinSearchParamsSchema,
921
- "\u641C\u7D22\u6570\u636E": DouyinSearchParamsSchema,
922
- "\u97F3\u4E50\u6570\u636E": DouyinMusicParamsSchema,
923
- "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E": DouyinLiveRoomParamsSchema,
924
- "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E": DouyinQrcodeParamsSchema,
925
- "Emoji\u6570\u636E": DouyinEmojiListParamsSchema,
926
- "\u52A8\u6001\u8868\u60C5\u6570\u636E": DouyinEmojiProParamsSchema,
927
- "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E": DouyinCommentReplyParamsSchema
928
- };
929
- var BilibiliVideoParamsSchema = z.object({
930
- methodType: z.literal("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
931
- bvid: z.string({ required_error: "BVID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "BVID\u4E0D\u80FD\u4E3A\u7A7A")
932
- });
933
- var BilibiliVideoDownloadParamsSchema = z.object({
934
- methodType: z.literal("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
935
- avid: smartNumber("AVID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
936
- cid: smartNumber("CID\u4E0D\u80FD\u4E3A\u7A7A", 1, true)
937
- });
938
- var BilibiliCommentParamsSchema = z.object({
939
- methodType: z.literal("\u8BC4\u8BBA\u6570\u636E"),
940
- oid: smartNumber("OID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
941
- type: smartNumber("\u8BC4\u8BBA\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A", 1, true).refine(
942
- (val) => [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 33].includes(val),
943
- { message: "\u65E0\u6548\u7684\u8BC4\u8BBA\u533A\u7C7B\u578B" }
944
- ),
945
- number: z.coerce.number().int().positive().default(20).optional(),
946
- pn: z.coerce.number().int().positive().default(1).optional()
947
- });
948
- var BilibiliUserParamsSchema = z.object({
949
- methodType: z.enum(["\u7528\u6237\u4E3B\u9875\u6570\u636E", "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E", "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF"]),
950
- host_mid: smartNumber("UP\u4E3BUID\u4E0D\u80FD\u4E3A\u7A7A", 1, true)
951
- });
952
- var BilibiliEmojiParamsSchema = z.object({
953
- methodType: z.literal("Emoji\u6570\u636E")
954
- });
955
- var BilibiliBangumiInfoParamsSchema = z.object({
956
- methodType: z.literal("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E"),
957
- ep_id: z.string().min(1, "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A").optional(),
958
- season_id: z.string().optional()
959
- }).refine(
960
- (data2) => data2.ep_id || data2.season_id,
961
- {
962
- message: "ep_id \u548C season_id \u81F3\u5C11\u9700\u8981\u63D0\u4F9B\u4E00\u4E2A",
963
- path: ["ep_id"]
861
+ // src/platform/douyin/sign/a_bogus.ts
862
+ var SM3 = class {
863
+ reg;
864
+ chunk;
865
+ size;
866
+ constructor() {
867
+ this.reg = [];
868
+ this.chunk = [];
869
+ this.size = 0;
870
+ this.reset();
964
871
  }
965
- );
966
- var BilibiliBangumiStreamParamsSchema = z.object({
967
- methodType: z.literal("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
968
- cid: smartNumber("CID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
969
- ep_id: z.string({ required_error: "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A")
970
- });
971
- var BilibiliDynamicParamsSchema = z.object({
972
- methodType: z.enum(["\u52A8\u6001\u8BE6\u60C5\u6570\u636E", "\u52A8\u6001\u5361\u7247\u6570\u636E"]),
973
- dynamic_id: z.string({ required_error: "\u52A8\u6001ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u52A8\u6001ID\u4E0D\u80FD\u4E3A\u7A7A")
974
- });
975
- var BilibiliLiveParamsSchema = z.object({
976
- methodType: z.enum(["\u76F4\u64AD\u95F4\u4FE1\u606F", "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"]),
977
- room_id: z.string({ required_error: "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A")
978
- });
979
- var BilibiliLoginParamsSchema = z.object({
980
- methodType: z.literal("\u767B\u5F55\u57FA\u672C\u4FE1\u606F")
981
- });
982
- var BilibiliQrcodeParamsSchema = z.object({
983
- methodType: z.literal("\u7533\u8BF7\u4E8C\u7EF4\u7801")
984
- });
985
- var BilibiliQrcodeStatusParamsSchema = z.object({
986
- methodType: z.literal("\u4E8C\u7EF4\u7801\u72B6\u6001"),
987
- qrcode_key: z.string({ required_error: "\u4E8C\u7EF4\u7801key\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u4E8C\u7EF4\u7801key\u4E0D\u80FD\u4E3A\u7A7A")
988
- });
989
- var BilibiliAv2BvParamsSchema = z.object({
990
- methodType: z.literal("AV\u8F6CBV"),
991
- avid: z.coerce.number({ required_error: "AVID\u4E0D\u80FD\u4E3A\u7A7A" }).int().positive()
992
- });
993
- var BilibiliBv2AvParamsSchema = z.object({
994
- methodType: z.literal("BV\u8F6CAV"),
995
- bvid: z.string({ required_error: "BVID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "BVID\u4E0D\u80FD\u4E3A\u7A7A")
996
- });
997
- var BilibiliValidationSchemas2 = {
998
- "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": BilibiliVideoParamsSchema,
999
- "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": BilibiliVideoDownloadParamsSchema,
1000
- "\u8BC4\u8BBA\u6570\u636E": BilibiliCommentParamsSchema,
1001
- "\u7528\u6237\u4E3B\u9875\u6570\u636E": BilibiliUserParamsSchema,
1002
- "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E": BilibiliUserParamsSchema,
1003
- "Emoji\u6570\u636E": BilibiliEmojiParamsSchema,
1004
- "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E": BilibiliBangumiInfoParamsSchema,
1005
- "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": BilibiliBangumiStreamParamsSchema,
1006
- "\u52A8\u6001\u8BE6\u60C5\u6570\u636E": BilibiliDynamicParamsSchema,
1007
- "\u52A8\u6001\u5361\u7247\u6570\u636E": BilibiliDynamicParamsSchema,
1008
- "\u76F4\u64AD\u95F4\u4FE1\u606F": BilibiliLiveParamsSchema,
1009
- "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F": BilibiliLiveParamsSchema,
1010
- "\u767B\u5F55\u57FA\u672C\u4FE1\u606F": BilibiliLoginParamsSchema,
1011
- "\u7533\u8BF7\u4E8C\u7EF4\u7801": BilibiliQrcodeParamsSchema,
1012
- "\u4E8C\u7EF4\u7801\u72B6\u6001": BilibiliQrcodeStatusParamsSchema,
1013
- "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF": BilibiliUserParamsSchema,
1014
- "AV\u8F6CBV": BilibiliAv2BvParamsSchema,
1015
- "BV\u8F6CAV": BilibiliBv2AvParamsSchema
1016
- };
1017
- var KuaishouVideoParamsSchema = z.object({
1018
- methodType: z.literal("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
1019
- photoId: z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A")
1020
- });
1021
- var KuaishouCommentParamsSchema = z.object({
1022
- methodType: z.literal("\u8BC4\u8BBA\u6570\u636E"),
1023
- photoId: z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A")
1024
- });
1025
- var KuaishouEmojiParamsSchema = z.object({
1026
- methodType: z.literal("Emoji\u6570\u636E")
1027
- });
1028
- var KuaishouValidationSchemas2 = {
1029
- "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": KuaishouVideoParamsSchema,
1030
- "\u8BC4\u8BBA\u6570\u636E": KuaishouCommentParamsSchema,
1031
- "Emoji\u6570\u636E": KuaishouEmojiParamsSchema
1032
- };
1033
-
1034
- // src/validation/index.ts
1035
- var validateDouyinParams = (methodType, params) => {
1036
- const schema = DouyinValidationSchemas2[methodType];
1037
- const validated = schema.parse(
1038
- typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
1039
- );
1040
- return validated;
1041
- };
1042
- var validateBilibiliParams = (methodType, params) => {
1043
- const schema = BilibiliValidationSchemas2[methodType];
1044
- const validated = schema.parse(
1045
- typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
1046
- );
1047
- return validated;
1048
- };
1049
- var validateKuaishouParams = (methodType, params) => {
1050
- const schema = KuaishouValidationSchemas2[methodType];
1051
- const validated = schema.parse(
1052
- typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
1053
- );
1054
- return validated;
1055
- };
1056
- var createApiResponse = (data2, message, code) => {
1057
- const dynamicSchema = z.object({
1058
- code: z.number().optional(),
1059
- message: z.string().optional(),
1060
- data: z.custom()
1061
- });
1062
- const validated = dynamicSchema.parse({
1063
- code,
1064
- message,
1065
- data: data2
1066
- });
1067
- return {
1068
- ...validated,
1069
- data: data2
1070
- };
1071
- };
1072
-
1073
- // src/platform/bilibili/BilibiliApi.ts
1074
- var bilibili = {
1075
- /**
1076
- * 获取单个视频作品数据
1077
- * @param options 请求参数,包含 bvid 和可选的 typeMode
1078
- * @param cookie 有效的用户 Cookie
1079
- * @returns 统一格式的API响应
1080
- */
1081
- getVideoInfo: async (options, cookie) => {
1082
- try {
1083
- const { typeMode, ...restOptions } = options;
1084
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
1085
- return createApiResponse(data2, "\u83B7\u53D6\u89C6\u9891\u4FE1\u606F\u6210\u529F", 200);
1086
- } catch (error) {
1087
- return createApiResponse(null, `\u83B7\u53D6\u89C6\u9891\u4FE1\u606F\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
872
+ reset() {
873
+ this.reg[0] = 1937774191;
874
+ this.reg[1] = 1226093241;
875
+ this.reg[2] = 388252375;
876
+ this.reg[3] = 3666478592;
877
+ this.reg[4] = 2842636476;
878
+ this.reg[5] = 372324522;
879
+ this.reg[6] = 3817729613;
880
+ this.reg[7] = 2969243214;
881
+ this.chunk = [];
882
+ this.size = 0;
883
+ }
884
+ write(e) {
885
+ const a = typeof e === "string" ? this.stringToBytes(e) : e;
886
+ this.size += a.length;
887
+ let f = 64 - this.chunk.length;
888
+ if (a.length < f) {
889
+ this.chunk = this.chunk.concat(a);
890
+ } else {
891
+ this.chunk = this.chunk.concat(a.slice(0, f));
892
+ while (this.chunk.length >= 64) {
893
+ this._compress(this.chunk);
894
+ f < a.length ? this.chunk = a.slice(f, Math.min(f + 64, a.length)) : this.chunk = [];
895
+ f += 64;
896
+ }
1088
897
  }
1089
- },
1090
- /**
1091
- * 获取单个视频下载信息数据
1092
- * @param options 请求参数,包含 avid, cid 和可选的 typeMode
1093
- * @param cookie 有效的用户 Cookie
1094
- * @returns 统一格式的API响应
1095
- */
1096
- getVideoStream: async (options, cookie) => {
1097
- try {
1098
- const { typeMode, ...restOptions } = options;
1099
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" }, cookie);
1100
- return createApiResponse(data2, "\u83B7\u53D6\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6210\u529F", 200);
1101
- } catch (error) {
1102
- return createApiResponse(null, `\u83B7\u53D6\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
1103
- }
1104
- },
1105
- /**
1106
- * 获取评论数据
1107
- * @param options 请求参数,包含 type, oid, 可选的 number, pn 和 typeMode
1108
- * @param cookie 有效的用户 Cookie
1109
- * @returns 统一格式的API响应
1110
- */
1111
- getComments: async (options, cookie) => {
1112
- try {
1113
- const { typeMode, ...restOptions } = options;
1114
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
1115
- return createApiResponse(data2, "\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u6210\u529F", 200);
1116
- } catch (error) {
1117
- return createApiResponse(null, `\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
1118
- }
1119
- },
1120
- /**
1121
- * 获取用户主页数据
1122
- * @param options 请求参数,包含 host_mid 和可选的 typeMode
1123
- * @param cookie 有效的用户 Cookie
1124
- * @returns 统一格式的API响应
1125
- */
1126
- getUserProfile: async (options, cookie) => {
1127
- try {
1128
- const { typeMode, ...restOptions } = options;
1129
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E" }, cookie);
1130
- return createApiResponse(data2, "\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u6570\u636E\u6210\u529F", 200);
1131
- } catch (error) {
1132
- return createApiResponse(null, `\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
1133
- }
1134
- },
1135
- /**
1136
- * 获取用户主页动态列表数据
1137
- * @param options 请求参数,包含 host_mid 和可选的 typeMode
1138
- * @param cookie 有效的用户 Cookie
1139
- * @returns 统一格式的API响应
1140
- */
1141
- getUserDynamic: async (options, cookie) => {
1142
- try {
1143
- const { typeMode, ...restOptions } = options;
1144
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E" }, cookie);
1145
- return createApiResponse(data2, "\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E\u6210\u529F", 200);
1146
- } catch (error) {
1147
- return createApiResponse(null, `\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
1148
- }
1149
- },
1150
- /**
1151
- * 获取 Emoji 数据
1152
- * @param options 可选的请求参数 (主要用于 typeMode)
1153
- * @param cookie 有效的用户 Cookie
1154
- * @returns 统一格式的API响应
1155
- */
1156
- getEmojiList: async (options, cookie) => {
1157
- try {
1158
- const { typeMode, ...restOptions } = options;
1159
- const data2 = await fetchBilibili({ ...restOptions, methodType: "Emoji\u6570\u636E" }, cookie);
1160
- return createApiResponse(data2, "\u83B7\u53D6Emoji\u6570\u636E\u6210\u529F", 200);
1161
- } catch (error) {
1162
- return createApiResponse(null, `\u83B7\u53D6Emoji\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
1163
- }
1164
- },
1165
- /**
1166
- * 获取番剧基本信息数据
1167
- * @param options 请求参数,包含可选的 season_id, ep_id 和 typeMode
1168
- * @param cookie 有效的用户 Cookie
1169
- * @returns 统一格式的API响应
1170
- */
1171
- getBangumiInfo: async (options, cookie) => {
1172
- try {
1173
- const { typeMode, ...restOptions } = options;
1174
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E" }, cookie);
1175
- return createApiResponse(data2, "\u83B7\u53D6\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E\u6210\u529F", 200);
1176
- } catch (error) {
1177
- return createApiResponse(null, `\u83B7\u53D6\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
1178
- }
1179
- },
1180
- /**
1181
- * 获取番剧下载信息数据
1182
- * @param options 请求参数,包含 cid, ep_id 和可选的 typeMode
1183
- * @param cookie 有效的用户 Cookie
1184
- * @returns 统一格式的API响应
1185
- */
1186
- getBangumiStream: async (options, cookie) => {
1187
- try {
1188
- const { typeMode, ...restOptions } = options;
1189
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" }, cookie);
1190
- return createApiResponse(data2, "\u83B7\u53D6\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E\u6210\u529F", 200);
1191
- } catch (error) {
1192
- return createApiResponse(null, `\u83B7\u53D6\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
1193
- }
1194
- },
1195
- /**
1196
- * 获取动态详情数据
1197
- * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
1198
- * @param cookie 有效的用户 Cookie
1199
- * @returns 统一格式的API响应
1200
- */
1201
- getDynamicInfo: async (options, cookie) => {
1202
- try {
1203
- const { typeMode, ...restOptions } = options;
1204
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E" }, cookie);
1205
- return createApiResponse(data2, "\u83B7\u53D6\u52A8\u6001\u8BE6\u60C5\u6570\u636E\u6210\u529F", 200);
1206
- } catch (error) {
1207
- return createApiResponse(null, `\u83B7\u53D6\u52A8\u6001\u8BE6\u60C5\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
1208
- }
1209
- },
1210
- /**
1211
- * 获取动态卡片数据
1212
- * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
1213
- * @param cookie 有效的用户 Cookie
1214
- * @returns 统一格式的API响应
1215
- */
1216
- getDynamicCard: async (options, cookie) => {
1217
- try {
1218
- const { typeMode, ...restOptions } = options;
1219
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u52A8\u6001\u5361\u7247\u6570\u636E" }, cookie);
1220
- return createApiResponse(data2, "\u83B7\u53D6\u52A8\u6001\u5361\u7247\u6570\u636E\u6210\u529F", 200);
1221
- } catch (error) {
1222
- return createApiResponse(null, `\u83B7\u53D6\u52A8\u6001\u5361\u7247\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
898
+ }
899
+ sum(e, t) {
900
+ if (e) {
901
+ this.reset();
902
+ this.write(e);
1223
903
  }
1224
- },
1225
- /**
1226
- * 获取直播间信息
1227
- * @param options 请求参数,包含 room_id 和可选的 typeMode
1228
- * @param cookie 有效的用户 Cookie
1229
- * @returns 统一格式的API响应
1230
- */
1231
- getLiveRoomDetail: async (options, cookie) => {
1232
- try {
1233
- const { typeMode, ...restOptions } = options;
1234
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F" }, cookie);
1235
- return createApiResponse(data2, "\u83B7\u53D6\u76F4\u64AD\u95F4\u4FE1\u606F\u6210\u529F", 200);
1236
- } catch (error) {
1237
- return createApiResponse(null, `\u83B7\u53D6\u76F4\u64AD\u95F4\u4FE1\u606F\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
904
+ this._fill();
905
+ for (let f = 0; f < this.chunk.length; f += 64) {
906
+ this._compress(this.chunk.slice(f, f + 64));
1238
907
  }
1239
- },
1240
- /**
1241
- * 获取直播间初始化信息
1242
- * @param options 请求参数,包含 room_id 和可选的 typeMode
1243
- * @param cookie 有效的用户 Cookie
1244
- * @returns 统一格式的API响应
1245
- */
1246
- getLiveRoomInitInfo: async (options, cookie) => {
1247
- try {
1248
- const { typeMode, ...restOptions } = options;
1249
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F" }, cookie);
1250
- return createApiResponse(data2, "\u83B7\u53D6\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F\u6210\u529F", 200);
1251
- } catch (error) {
1252
- return createApiResponse(null, `\u83B7\u53D6\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
908
+ let i = null;
909
+ if (t === "hex") {
910
+ i = "";
911
+ for (let f = 0; f < 8; f++) {
912
+ i += this.padHex(this.reg[f].toString(16), 8);
913
+ }
914
+ } else {
915
+ i = new Array(32);
916
+ for (let f = 0; f < 8; f++) {
917
+ let c = this.reg[f];
918
+ i[4 * f + 3] = (255 & c) >>> 0;
919
+ c >>>= 8;
920
+ i[4 * f + 2] = (255 & c) >>> 0;
921
+ c >>>= 8;
922
+ i[4 * f + 1] = (255 & c) >>> 0;
923
+ c >>>= 8;
924
+ i[4 * f] = (255 & c) >>> 0;
925
+ }
1253
926
  }
1254
- },
1255
- /**
1256
- * 获取登录基本信息
1257
- * @param options 可选的请求参数 (主要用于 typeMode)
1258
- * @param cookie 有效的用户 Cookie
1259
- * @returns 统一格式的API响应
1260
- */
1261
- getLoginBasicInfo: async (options, cookie) => {
1262
- try {
1263
- const { typeMode, ...restOptions } = options;
1264
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F" }, cookie);
1265
- return createApiResponse(data2, "\u83B7\u53D6\u767B\u5F55\u57FA\u672C\u4FE1\u606F\u6210\u529F", 200);
1266
- } catch (error) {
1267
- return createApiResponse(null, `\u83B7\u53D6\u767B\u5F55\u57FA\u672C\u4FE1\u606F\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
927
+ this.reset();
928
+ return i;
929
+ }
930
+ _compress(t) {
931
+ if (t.length < 64) {
932
+ console.error("compress error: not enough data");
933
+ } else {
934
+ for (var f = ((e) => {
935
+ for (var r = new Array(132), t2 = 0; t2 < 16; t2++) {
936
+ r[t2] = e[4 * t2] << 24, r[t2] |= e[4 * t2 + 1] << 16, r[t2] |= e[4 * t2 + 2] << 8, r[t2] |= e[4 * t2 + 3], r[t2] >>>= 0;
937
+ }
938
+ for (var n = 16; n < 68; n++) {
939
+ let a = r[n - 16] ^ r[n - 9] ^ this.le(r[n - 3], 15);
940
+ a = a ^ this.le(a, 15) ^ this.le(a, 23), r[n] = (a ^ this.le(r[n - 13], 7) ^ r[n - 6]) >>> 0;
941
+ }
942
+ for (n = 0; n < 64; n++) r[n + 68] = (r[n] ^ r[n + 4]) >>> 0;
943
+ return r;
944
+ })(t), i = this.reg.slice(0), c = 0; c < 64; c++) {
945
+ let o = this.le(i[0], 12) + i[4] + this.le(this.de(c), c);
946
+ const s = ((o = this.le(o = (4294967295 & o) >>> 0, 7)) ^ this.le(i[0], 12)) >>> 0;
947
+ let u = this.pe(c, i[0], i[1], i[2]);
948
+ u = (4294967295 & (u = u + i[3] + s + f[c + 68])) >>> 0;
949
+ let b = this.he(c, i[4], i[5], i[6]);
950
+ b = (4294967295 & (b = b + i[7] + o + f[c])) >>> 0, i[3] = i[2], i[2] = this.le(i[1], 9), i[1] = i[0], i[0] = u, i[7] = i[6], i[6] = this.le(i[5], 19), i[5] = i[4], i[4] = (b ^ this.le(b, 9) ^ this.le(b, 17)) >>> 0;
951
+ }
952
+ for (let l = 0; l < 8; l++) this.reg[l] = (this.reg[l] ^ i[l]) >>> 0;
1268
953
  }
1269
- },
1270
- /**
1271
- * 申请登录二维码
1272
- * @param options 可选的请求参数 (主要用于 typeMode)
1273
- * @param cookie 有效的用户 Cookie
1274
- * @returns 统一格式的API响应
1275
- */
1276
- getLoginQrcode: async (options, cookie) => {
1277
- try {
1278
- const { typeMode, ...restOptions } = options;
1279
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801" }, cookie);
1280
- return createApiResponse(data2, "\u7533\u8BF7\u767B\u5F55\u4E8C\u7EF4\u7801\u6210\u529F", 200);
1281
- } catch (error) {
1282
- return createApiResponse(null, `\u7533\u8BF7\u767B\u5F55\u4E8C\u7EF4\u7801\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
954
+ }
955
+ _fill() {
956
+ let a = 8 * this.size;
957
+ let f = this.chunk.push(128) % 64;
958
+ while (64 - f < 8) {
959
+ f -= 64;
1283
960
  }
1284
- },
1285
- /**
1286
- * 检查二维码状态
1287
- * @param options 请求参数,包含 qrcode_key 和可选的 typeMode
1288
- * @param cookie 有效的用户 Cookie
1289
- * @returns 统一格式的API响应
1290
- */
1291
- checkQrcodeStatus: async (options, cookie) => {
1292
- try {
1293
- const { typeMode, ...restOptions } = options;
1294
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u4E8C\u7EF4\u7801\u72B6\u6001" }, cookie);
1295
- return createApiResponse(data2, "\u68C0\u67E5\u4E8C\u7EF4\u7801\u72B6\u6001\u6210\u529F", 200);
1296
- } catch (error) {
1297
- return createApiResponse(null, `\u68C0\u67E5\u4E8C\u7EF4\u7801\u72B6\u6001\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
961
+ while (f < 56) {
962
+ this.chunk.push(0);
963
+ f++;
1298
964
  }
1299
- },
1300
- /**
1301
- * 获取 UP 主总播放量
1302
- * @param options 请求参数,包含 host_mid 和可选的 typeMode
1303
- * @param cookie 有效的用户 Cookie
1304
- * @returns 统一格式的API响应
1305
- */
1306
- getUserTotalPlayCount: async (options, cookie) => {
1307
- try {
1308
- const { typeMode, ...restOptions } = options;
1309
- const data2 = await fetchBilibili({ ...restOptions, methodType: "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF" }, cookie);
1310
- return createApiResponse(data2, "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF\u6210\u529F", 200);
1311
- } catch (error) {
1312
- return createApiResponse(null, `\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
965
+ for (let i = 0; i < 4; i++) {
966
+ const c = Math.floor(a / 4294967296);
967
+ this.chunk.push(c >>> 8 * (3 - i) & 255);
1313
968
  }
1314
- },
1315
- /**
1316
- * 将 AV 号转换为 BV 号
1317
- * @param options 请求参数,包含 avid 和可选的 typeMode
1318
- * @param cookie 有效的用户 Cookie (此接口通常不需要)
1319
- * @returns 统一格式的API响应
1320
- */
1321
- convertAvToBv: async (options, cookie) => {
1322
- try {
1323
- const { typeMode, ...restOptions } = options;
1324
- const data2 = await fetchBilibili({ ...restOptions, methodType: "AV\u8F6CBV" }, cookie);
1325
- return createApiResponse(data2, "AV\u53F7\u8F6C\u6362\u4E3ABV\u53F7\u6210\u529F", 200);
1326
- } catch (error) {
1327
- return createApiResponse(null, `AV\u53F7\u8F6C\u6362\u4E3ABV\u53F7\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
969
+ for (let i = 0; i < 4; i++) {
970
+ this.chunk.push(a >>> 8 * (3 - i) & 255);
1328
971
  }
1329
- },
1330
- /**
1331
- * 将 BV 号转换为 AV 号
1332
- * @param options 请求参数,包含 bvid 和可选的 typeMode
1333
- * @param cookie 有效的用户 Cookie (此接口通常不需要)
1334
- * @returns 统一格式的API响应
1335
- */
1336
- convertBvToAv: async (options, cookie) => {
1337
- try {
1338
- const { typeMode, ...restOptions } = options;
1339
- const data2 = await fetchBilibili({ ...restOptions, methodType: "BV\u8F6CAV" }, cookie);
1340
- return createApiResponse(data2, "BV\u53F7\u8F6C\u6362\u4E3AAV\u53F7\u6210\u529F", 200);
1341
- } catch (error) {
1342
- return createApiResponse(null, `BV\u53F7\u8F6C\u6362\u4E3AAV\u53F7\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
972
+ }
973
+ de(e) {
974
+ return e >= 0 && e < 16 ? 2043430169 : e >= 16 && e < 64 ? 2055708042 : (console.error("invalid j for constant Tj"), 0);
975
+ }
976
+ pe(e, r, t, n) {
977
+ return e >= 0 && e < 16 ? (r ^ t ^ n) >>> 0 : e >= 16 && e < 64 ? (r & t | r & n | t & n) >>> 0 : (console.error("invalid j for bool function FF"), 0);
978
+ }
979
+ he(e, r, t, n) {
980
+ return e >= 0 && e < 16 ? (r ^ t ^ n) >>> 0 : e >= 16 && e < 64 ? (r & t | ~r & n) >>> 0 : (console.error("invalid j for bool function GG"), 0);
981
+ }
982
+ le(e, r) {
983
+ return (e << (r %= 32) | e >>> 32 - r) >>> 0;
984
+ }
985
+ stringToBytes(str) {
986
+ const n = encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_, r) => String.fromCharCode(parseInt(r, 16)));
987
+ const a = new Array(n.length);
988
+ for (let i = 0; i < n.length; i++) {
989
+ a[i] = n.charCodeAt(i);
1343
990
  }
991
+ return a;
1344
992
  }
1345
- };
1346
- var ApiError = class extends Error {
1347
- code;
1348
- platform;
1349
- /**
1350
- * 构造API错误
1351
- * @param message - 错误消息
1352
- * @param code - 错误代码
1353
- * @param platform - 平台名称
1354
- */
1355
- constructor(message, code = 500, platform = "unknown") {
1356
- super(message);
1357
- this.name = "ApiError";
1358
- this.code = code;
1359
- this.platform = platform;
1360
- }
1361
- };
1362
- var ValidationError = class _ValidationError extends Error {
1363
- errors;
1364
- requestPath;
1365
- /**
1366
- * 构造参数验证错误
1367
- * @param message - 错误消息
1368
- * @param errors - 详细错误信息
1369
- * @param requestPath - HTTP请求路径
1370
- */
1371
- constructor(message, errors, requestPath) {
1372
- super(message);
1373
- this.name = "ValidationError";
1374
- this.errors = errors;
1375
- this.requestPath = requestPath;
1376
- }
1377
- /**
1378
- * 从Zod错误创建验证错误
1379
- * @param zodError - Zod验证错误
1380
- * @param requestPath - HTTP请求路径
1381
- * @returns 验证错误实例
1382
- */
1383
- static fromZodError(zodError, requestPath) {
1384
- const errors = zodError.errors.map((err) => ({
1385
- field: err.path.join("."),
1386
- message: err.message
1387
- }));
1388
- return new _ValidationError("\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25", errors, requestPath);
1389
- }
1390
- };
1391
- var handleError = (error, requestPath) => {
1392
- if (error instanceof ValidationError) {
1393
- return {
1394
- code: 400,
1395
- message: error.message,
1396
- data: null,
1397
- errors: error.errors,
1398
- requestPath: error.requestPath || requestPath
1399
- };
1400
- }
1401
- if (error instanceof ApiError) {
1402
- return {
1403
- code: error.code,
1404
- message: error.message,
1405
- data: null,
1406
- platform: error.platform,
1407
- requestPath
1408
- };
1409
- }
1410
- if (error instanceof z.ZodError) {
1411
- const validationError = ValidationError.fromZodError(error, requestPath);
1412
- return handleError(validationError, requestPath);
1413
- }
1414
- const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
1415
- return {
1416
- code: 500,
1417
- message: errorMessage,
1418
- data: null,
1419
- requestPath
1420
- };
1421
- };
1422
-
1423
- // src/middleware/validation.ts
1424
- var createValidationMiddleware = (validateFn, methodType) => {
1425
- return (req, res, next) => {
1426
- try {
1427
- const params = { ...req.query, ...req.body };
1428
- const validatedParams = validateFn(methodType, params);
1429
- req.validatedParams = validatedParams;
1430
- next();
1431
- } catch (error) {
1432
- const errorResponse = handleError(error, req.originalUrl);
1433
- res.status(errorResponse.code || 500).json(errorResponse);
1434
- }
1435
- };
1436
- };
1437
- var createDouyinValidationMiddleware = (methodType) => createValidationMiddleware(validateDouyinParams, methodType);
1438
- var createBilibiliValidationMiddleware = (methodType) => createValidationMiddleware(validateBilibiliParams, methodType);
1439
- var createKuaishouValidationMiddleware = (methodType) => createValidationMiddleware(validateKuaishouParams, methodType);
1440
-
1441
- // src/platform/douyin/sign/a_bogus.ts
1442
- var SM3 = class {
1443
- reg;
1444
- chunk;
1445
- size;
1446
- constructor() {
1447
- this.reg = [];
1448
- this.chunk = [];
1449
- this.size = 0;
1450
- this.reset();
1451
- }
1452
- reset() {
1453
- this.reg[0] = 1937774191;
1454
- this.reg[1] = 1226093241;
1455
- this.reg[2] = 388252375;
1456
- this.reg[3] = 3666478592;
1457
- this.reg[4] = 2842636476;
1458
- this.reg[5] = 372324522;
1459
- this.reg[6] = 3817729613;
1460
- this.reg[7] = 2969243214;
1461
- this.chunk = [];
1462
- this.size = 0;
1463
- }
1464
- write(e) {
1465
- const a = typeof e === "string" ? this.stringToBytes(e) : e;
1466
- this.size += a.length;
1467
- let f = 64 - this.chunk.length;
1468
- if (a.length < f) {
1469
- this.chunk = this.chunk.concat(a);
1470
- } else {
1471
- this.chunk = this.chunk.concat(a.slice(0, f));
1472
- while (this.chunk.length >= 64) {
1473
- this._compress(this.chunk);
1474
- f < a.length ? this.chunk = a.slice(f, Math.min(f + 64, a.length)) : this.chunk = [];
1475
- f += 64;
1476
- }
1477
- }
1478
- }
1479
- sum(e, t) {
1480
- if (e) {
1481
- this.reset();
1482
- this.write(e);
1483
- }
1484
- this._fill();
1485
- for (let f = 0; f < this.chunk.length; f += 64) {
1486
- this._compress(this.chunk.slice(f, f + 64));
1487
- }
1488
- let i = null;
1489
- if (t === "hex") {
1490
- i = "";
1491
- for (let f = 0; f < 8; f++) {
1492
- i += this.padHex(this.reg[f].toString(16), 8);
1493
- }
1494
- } else {
1495
- i = new Array(32);
1496
- for (let f = 0; f < 8; f++) {
1497
- let c = this.reg[f];
1498
- i[4 * f + 3] = (255 & c) >>> 0;
1499
- c >>>= 8;
1500
- i[4 * f + 2] = (255 & c) >>> 0;
1501
- c >>>= 8;
1502
- i[4 * f + 1] = (255 & c) >>> 0;
1503
- c >>>= 8;
1504
- i[4 * f] = (255 & c) >>> 0;
1505
- }
1506
- }
1507
- this.reset();
1508
- return i;
1509
- }
1510
- _compress(t) {
1511
- if (t.length < 64) {
1512
- console.error("compress error: not enough data");
1513
- } else {
1514
- for (var f = ((e) => {
1515
- for (var r = new Array(132), t2 = 0; t2 < 16; t2++) {
1516
- r[t2] = e[4 * t2] << 24, r[t2] |= e[4 * t2 + 1] << 16, r[t2] |= e[4 * t2 + 2] << 8, r[t2] |= e[4 * t2 + 3], r[t2] >>>= 0;
1517
- }
1518
- for (var n = 16; n < 68; n++) {
1519
- let a = r[n - 16] ^ r[n - 9] ^ this.le(r[n - 3], 15);
1520
- a = a ^ this.le(a, 15) ^ this.le(a, 23), r[n] = (a ^ this.le(r[n - 13], 7) ^ r[n - 6]) >>> 0;
1521
- }
1522
- for (n = 0; n < 64; n++) r[n + 68] = (r[n] ^ r[n + 4]) >>> 0;
1523
- return r;
1524
- })(t), i = this.reg.slice(0), c = 0; c < 64; c++) {
1525
- let o = this.le(i[0], 12) + i[4] + this.le(this.de(c), c);
1526
- const s = ((o = this.le(o = (4294967295 & o) >>> 0, 7)) ^ this.le(i[0], 12)) >>> 0;
1527
- let u = this.pe(c, i[0], i[1], i[2]);
1528
- u = (4294967295 & (u = u + i[3] + s + f[c + 68])) >>> 0;
1529
- let b = this.he(c, i[4], i[5], i[6]);
1530
- b = (4294967295 & (b = b + i[7] + o + f[c])) >>> 0, i[3] = i[2], i[2] = this.le(i[1], 9), i[1] = i[0], i[0] = u, i[7] = i[6], i[6] = this.le(i[5], 19), i[5] = i[4], i[4] = (b ^ this.le(b, 9) ^ this.le(b, 17)) >>> 0;
1531
- }
1532
- for (let l = 0; l < 8; l++) this.reg[l] = (this.reg[l] ^ i[l]) >>> 0;
1533
- }
1534
- }
1535
- _fill() {
1536
- let a = 8 * this.size;
1537
- let f = this.chunk.push(128) % 64;
1538
- while (64 - f < 8) {
1539
- f -= 64;
1540
- }
1541
- while (f < 56) {
1542
- this.chunk.push(0);
1543
- f++;
1544
- }
1545
- for (let i = 0; i < 4; i++) {
1546
- const c = Math.floor(a / 4294967296);
1547
- this.chunk.push(c >>> 8 * (3 - i) & 255);
1548
- }
1549
- for (let i = 0; i < 4; i++) {
1550
- this.chunk.push(a >>> 8 * (3 - i) & 255);
1551
- }
1552
- }
1553
- de(e) {
1554
- return e >= 0 && e < 16 ? 2043430169 : e >= 16 && e < 64 ? 2055708042 : (console.error("invalid j for constant Tj"), 0);
1555
- }
1556
- pe(e, r, t, n) {
1557
- return e >= 0 && e < 16 ? (r ^ t ^ n) >>> 0 : e >= 16 && e < 64 ? (r & t | r & n | t & n) >>> 0 : (console.error("invalid j for bool function FF"), 0);
1558
- }
1559
- he(e, r, t, n) {
1560
- return e >= 0 && e < 16 ? (r ^ t ^ n) >>> 0 : e >= 16 && e < 64 ? (r & t | ~r & n) >>> 0 : (console.error("invalid j for bool function GG"), 0);
1561
- }
1562
- le(e, r) {
1563
- return (e << (r %= 32) | e >>> 32 - r) >>> 0;
1564
- }
1565
- stringToBytes(str) {
1566
- const n = encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_, r) => String.fromCharCode(parseInt(r, 16)));
1567
- const a = new Array(n.length);
1568
- for (let i = 0; i < n.length; i++) {
1569
- a[i] = n.charCodeAt(i);
1570
- }
1571
- return a;
1572
- }
1573
- padHex(num, size) {
1574
- return num.padStart(size, "0");
993
+ padHex(num, size) {
994
+ return num.padStart(size, "0");
1575
995
  }
1576
996
  };
1577
997
  function rc4_encrypt(plaintext, key) {
@@ -1899,7 +1319,6 @@ var DouyinAPI = class {
1899
1319
  return `https://sso.douyin.com/get_qrcode/?verifyFp=${data2.verify_fp}&fp=${data2.verify_fp}`;
1900
1320
  }
1901
1321
  };
1902
- var douyinAPI = new DouyinAPI();
1903
1322
  var douyinApiUrls = new DouyinAPI();
1904
1323
 
1905
1324
  // src/platform/douyin/getdata.ts
@@ -2246,8 +1665,6 @@ var API = class {
2246
1665
  };
2247
1666
  }
2248
1667
  };
2249
- var KuaishouAPI = new API();
2250
- var kuaishouAPI = new API();
2251
1668
  var kuaishouApiUrls = new API();
2252
1669
 
2253
1670
  // src/platform/kuaishou/getdata.ts
@@ -2303,119 +1720,689 @@ var KuaishouData = async (data2, cookie) => {
2303
1720
  return null;
2304
1721
  }
2305
1722
  };
2306
- var GlobalGetData3 = async (options) => {
2307
- let warningMessage = "";
2308
- try {
2309
- const result = await new Networks(options).getData();
2310
- if (result === "" || !result || result.result === 2) {
2311
- const Err = {
2312
- errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF01`,
2313
- requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
2314
- requestUrl: options.url,
2315
- requestBody: JSON.stringify(options.body)
2316
- };
2317
- warningMessage = `
2318
- \u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow("\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684\u5FEB\u624Bck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01")}
2319
- \u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
2320
- \u8BF7\u6C42URL\uFF1A${options.url}
2321
- \u8BF7\u6C42\u53C2\u6570\uFF1A${JSON.stringify(options.body, null, 2)}
2322
- `;
2323
- logger.warn(warningMessage);
2324
- throw {
2325
- code: "INVALID_COOKIE" /* COOKIE */,
2326
- data: result,
2327
- amagiError: Err
2328
- };
2329
- }
2330
- return result;
2331
- } catch (error) {
2332
- if (error && typeof error === "object") {
2333
- const err = error;
2334
- return { ...err, amagiMessage: warningMessage };
2335
- }
1723
+ var GlobalGetData3 = async (options) => {
1724
+ let warningMessage = "";
1725
+ try {
1726
+ const result = await new Networks(options).getData();
1727
+ if (result === "" || !result || result.result === 2) {
1728
+ const Err = {
1729
+ errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF01`,
1730
+ requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
1731
+ requestUrl: options.url,
1732
+ requestBody: JSON.stringify(options.body)
1733
+ };
1734
+ warningMessage = `
1735
+ \u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow("\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684\u5FEB\u624Bck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01")}
1736
+ \u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
1737
+ \u8BF7\u6C42URL\uFF1A${options.url}
1738
+ \u8BF7\u6C42\u53C2\u6570\uFF1A${JSON.stringify(options.body, null, 2)}
1739
+ `;
1740
+ logger.warn(warningMessage);
1741
+ throw {
1742
+ code: "INVALID_COOKIE" /* COOKIE */,
1743
+ data: result,
1744
+ amagiError: Err
1745
+ };
1746
+ }
1747
+ return result;
1748
+ } catch (error) {
1749
+ if (error && typeof error === "object") {
1750
+ const err = error;
1751
+ return { ...err, amagiMessage: warningMessage };
1752
+ }
1753
+ return {
1754
+ code: "UNKNOWN_ERROR" /* UNKNOWN */,
1755
+ data: null,
1756
+ amagiError: {
1757
+ errorDescription: "\u672A\u77E5\u9519\u8BEF",
1758
+ requestType: options.methodType,
1759
+ requestUrl: options.url
1760
+ },
1761
+ amagiMessage: warningMessage
1762
+ };
1763
+ }
1764
+ };
1765
+ function smartNumber(errorMessage, minValue = 1, isInteger = false) {
1766
+ if (isInteger) {
1767
+ return z.coerce.number({ required_error: errorMessage }).int(`${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u662F\u6574\u6570\uFF0C\u4E0D\u80FD\u5305\u542B\u5C0F\u6570`).min(minValue, `${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E${minValue}`);
1768
+ } else {
1769
+ return z.coerce.number({ required_error: errorMessage }).min(minValue, `${errorMessage.replace("\u4E0D\u80FD\u4E3A\u7A7A", "")}\u5FC5\u987B\u5927\u4E8E\u7B49\u4E8E${minValue}`);
1770
+ }
1771
+ }
1772
+ var smartPositiveInteger = (errorMessage) => {
1773
+ return smartNumber(errorMessage, 1, true);
1774
+ };
1775
+
1776
+ // src/validation/douyin.ts
1777
+ var DouyinWorkParamsSchema = z.object({
1778
+ methodType: z.enum(["\u89C6\u9891\u4F5C\u54C1\u6570\u636E", "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E", "\u5408\u8F91\u4F5C\u54C1\u6570\u636E", "\u805A\u5408\u89E3\u6790"]),
1779
+ aweme_id: z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A")
1780
+ });
1781
+ var DouyinCommentParamsSchema = z.object({
1782
+ methodType: z.literal("\u8BC4\u8BBA\u6570\u636E"),
1783
+ aweme_id: z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A"),
1784
+ number: smartPositiveInteger("\u8BC4\u8BBA\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(50),
1785
+ cursor: z.coerce.number().int().min(0).default(0).optional()
1786
+ });
1787
+ var DouyinSearchParamsSchema = z.object({
1788
+ methodType: z.enum(["\u70ED\u70B9\u8BCD\u6570\u636E", "\u641C\u7D22\u6570\u636E"]),
1789
+ query: z.string({ required_error: "\u641C\u7D22\u8BCD\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u641C\u7D22\u8BCD\u4E0D\u80FD\u4E3A\u7A7A"),
1790
+ number: smartPositiveInteger("\u641C\u7D22\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(10),
1791
+ search_id: z.string().optional()
1792
+ });
1793
+ var DouyinCommentReplyParamsSchema = z.object({
1794
+ methodType: z.literal("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E"),
1795
+ aweme_id: z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A"),
1796
+ comment_id: z.string({ required_error: "\u8BC4\u8BBAID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u8BC4\u8BBAID\u4E0D\u80FD\u4E3A\u7A7A"),
1797
+ number: smartPositiveInteger("\u8BC4\u8BBA\u6570\u91CF\u5FC5\u987B\u662F\u6B63\u6574\u6570").optional().default(5),
1798
+ cursor: z.coerce.number().int().min(0).default(0).optional()
1799
+ });
1800
+ var DouyinUserParamsSchema = z.object({
1801
+ methodType: z.enum(["\u7528\u6237\u4E3B\u9875\u6570\u636E", "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E", "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E"]),
1802
+ sec_uid: z.string({ required_error: "\u7528\u6237ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u7528\u6237ID\u4E0D\u80FD\u4E3A\u7A7A")
1803
+ });
1804
+ var DouyinMusicParamsSchema = z.object({
1805
+ methodType: z.literal("\u97F3\u4E50\u6570\u636E"),
1806
+ music_id: z.string({ required_error: "\u97F3\u4E50ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u97F3\u4E50ID\u4E0D\u80FD\u4E3A\u7A7A")
1807
+ });
1808
+ var DouyinQrcodeParamsSchema = z.object({
1809
+ methodType: z.literal("\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E"),
1810
+ verify_fp: z.string({ required_error: "fp\u6307\u7EB9\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "fp\u6307\u7EB9\u4E0D\u80FD\u4E3A\u7A7A")
1811
+ });
1812
+ var DouyinEmojiListParamsSchema = z.object({
1813
+ methodType: z.literal("Emoji\u6570\u636E")
1814
+ });
1815
+ var DouyinEmojiProParamsSchema = z.object({
1816
+ methodType: z.literal("\u52A8\u6001\u8868\u60C5\u6570\u636E")
1817
+ });
1818
+ var DouyinValidationSchemas2 = {
1819
+ "\u805A\u5408\u89E3\u6790": DouyinWorkParamsSchema,
1820
+ "\u89C6\u9891\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
1821
+ "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
1822
+ "\u5408\u8F91\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
1823
+ "\u8BC4\u8BBA\u6570\u636E": DouyinCommentParamsSchema,
1824
+ "\u7528\u6237\u4E3B\u9875\u6570\u636E": DouyinUserParamsSchema,
1825
+ "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E": DouyinUserParamsSchema,
1826
+ "\u70ED\u70B9\u8BCD\u6570\u636E": DouyinSearchParamsSchema,
1827
+ "\u641C\u7D22\u6570\u636E": DouyinSearchParamsSchema,
1828
+ "\u97F3\u4E50\u6570\u636E": DouyinMusicParamsSchema,
1829
+ "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E": DouyinUserParamsSchema,
1830
+ "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E": DouyinQrcodeParamsSchema,
1831
+ "Emoji\u6570\u636E": DouyinEmojiListParamsSchema,
1832
+ "\u52A8\u6001\u8868\u60C5\u6570\u636E": DouyinEmojiProParamsSchema,
1833
+ "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E": DouyinCommentReplyParamsSchema
1834
+ };
1835
+ var BilibiliVideoParamsSchema = z.object({
1836
+ methodType: z.literal("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
1837
+ bvid: z.string({ required_error: "BVID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "BVID\u4E0D\u80FD\u4E3A\u7A7A")
1838
+ });
1839
+ var BilibiliVideoDownloadParamsSchema = z.object({
1840
+ methodType: z.literal("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
1841
+ avid: smartNumber("AVID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
1842
+ cid: smartNumber("CID\u4E0D\u80FD\u4E3A\u7A7A", 1, true)
1843
+ });
1844
+ var BilibiliCommentParamsSchema = z.object({
1845
+ methodType: z.literal("\u8BC4\u8BBA\u6570\u636E"),
1846
+ oid: smartNumber("OID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
1847
+ type: smartNumber("\u8BC4\u8BBA\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A", 1, true).refine(
1848
+ (val) => [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 33].includes(val),
1849
+ { message: "\u65E0\u6548\u7684\u8BC4\u8BBA\u533A\u7C7B\u578B" }
1850
+ ),
1851
+ number: z.coerce.number().int().positive().default(20).optional(),
1852
+ pn: z.coerce.number().int().positive().default(1).optional()
1853
+ });
1854
+ var BilibiliUserParamsSchema = z.object({
1855
+ methodType: z.enum(["\u7528\u6237\u4E3B\u9875\u6570\u636E", "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E", "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF"]),
1856
+ host_mid: smartNumber("UP\u4E3BUID\u4E0D\u80FD\u4E3A\u7A7A", 1, true)
1857
+ });
1858
+ var BilibiliEmojiParamsSchema = z.object({
1859
+ methodType: z.literal("Emoji\u6570\u636E")
1860
+ });
1861
+ var BilibiliBangumiInfoParamsSchema = z.object({
1862
+ methodType: z.literal("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E"),
1863
+ ep_id: z.string().min(1, "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A").optional(),
1864
+ season_id: z.string().optional()
1865
+ }).refine(
1866
+ (data2) => data2.ep_id || data2.season_id,
1867
+ {
1868
+ message: "ep_id \u548C season_id \u81F3\u5C11\u9700\u8981\u63D0\u4F9B\u4E00\u4E2A",
1869
+ path: ["ep_id"]
1870
+ }
1871
+ );
1872
+ var BilibiliBangumiStreamParamsSchema = z.object({
1873
+ methodType: z.literal("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
1874
+ cid: smartNumber("CID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
1875
+ ep_id: z.string({ required_error: "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A")
1876
+ });
1877
+ var BilibiliDynamicParamsSchema = z.object({
1878
+ methodType: z.enum(["\u52A8\u6001\u8BE6\u60C5\u6570\u636E", "\u52A8\u6001\u5361\u7247\u6570\u636E"]),
1879
+ dynamic_id: z.string({ required_error: "\u52A8\u6001ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u52A8\u6001ID\u4E0D\u80FD\u4E3A\u7A7A")
1880
+ });
1881
+ var BilibiliLiveParamsSchema = z.object({
1882
+ methodType: z.enum(["\u76F4\u64AD\u95F4\u4FE1\u606F", "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"]),
1883
+ room_id: z.string({ required_error: "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A")
1884
+ });
1885
+ var BilibiliLoginParamsSchema = z.object({
1886
+ methodType: z.literal("\u767B\u5F55\u57FA\u672C\u4FE1\u606F")
1887
+ });
1888
+ var BilibiliQrcodeParamsSchema = z.object({
1889
+ methodType: z.literal("\u7533\u8BF7\u4E8C\u7EF4\u7801")
1890
+ });
1891
+ var BilibiliQrcodeStatusParamsSchema = z.object({
1892
+ methodType: z.literal("\u4E8C\u7EF4\u7801\u72B6\u6001"),
1893
+ qrcode_key: z.string({ required_error: "\u4E8C\u7EF4\u7801key\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u4E8C\u7EF4\u7801key\u4E0D\u80FD\u4E3A\u7A7A")
1894
+ });
1895
+ var BilibiliAv2BvParamsSchema = z.object({
1896
+ methodType: z.literal("AV\u8F6CBV"),
1897
+ avid: z.coerce.number({ required_error: "AVID\u4E0D\u80FD\u4E3A\u7A7A" }).int().positive()
1898
+ });
1899
+ var BilibiliBv2AvParamsSchema = z.object({
1900
+ methodType: z.literal("BV\u8F6CAV"),
1901
+ bvid: z.string({ required_error: "BVID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "BVID\u4E0D\u80FD\u4E3A\u7A7A")
1902
+ });
1903
+ var BilibiliValidationSchemas2 = {
1904
+ "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": BilibiliVideoParamsSchema,
1905
+ "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": BilibiliVideoDownloadParamsSchema,
1906
+ "\u8BC4\u8BBA\u6570\u636E": BilibiliCommentParamsSchema,
1907
+ "\u7528\u6237\u4E3B\u9875\u6570\u636E": BilibiliUserParamsSchema,
1908
+ "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E": BilibiliUserParamsSchema,
1909
+ "Emoji\u6570\u636E": BilibiliEmojiParamsSchema,
1910
+ "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E": BilibiliBangumiInfoParamsSchema,
1911
+ "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": BilibiliBangumiStreamParamsSchema,
1912
+ "\u52A8\u6001\u8BE6\u60C5\u6570\u636E": BilibiliDynamicParamsSchema,
1913
+ "\u52A8\u6001\u5361\u7247\u6570\u636E": BilibiliDynamicParamsSchema,
1914
+ "\u76F4\u64AD\u95F4\u4FE1\u606F": BilibiliLiveParamsSchema,
1915
+ "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F": BilibiliLiveParamsSchema,
1916
+ "\u767B\u5F55\u57FA\u672C\u4FE1\u606F": BilibiliLoginParamsSchema,
1917
+ "\u7533\u8BF7\u4E8C\u7EF4\u7801": BilibiliQrcodeParamsSchema,
1918
+ "\u4E8C\u7EF4\u7801\u72B6\u6001": BilibiliQrcodeStatusParamsSchema,
1919
+ "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF": BilibiliUserParamsSchema,
1920
+ "AV\u8F6CBV": BilibiliAv2BvParamsSchema,
1921
+ "BV\u8F6CAV": BilibiliBv2AvParamsSchema
1922
+ };
1923
+ var KuaishouVideoParamsSchema = z.object({
1924
+ methodType: z.literal("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
1925
+ photoId: z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A")
1926
+ });
1927
+ var KuaishouCommentParamsSchema = z.object({
1928
+ methodType: z.literal("\u8BC4\u8BBA\u6570\u636E"),
1929
+ photoId: z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A")
1930
+ });
1931
+ var KuaishouEmojiParamsSchema = z.object({
1932
+ methodType: z.literal("Emoji\u6570\u636E")
1933
+ });
1934
+ var KuaishouValidationSchemas2 = {
1935
+ "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": KuaishouVideoParamsSchema,
1936
+ "\u8BC4\u8BBA\u6570\u636E": KuaishouCommentParamsSchema,
1937
+ "Emoji\u6570\u636E": KuaishouEmojiParamsSchema
1938
+ };
1939
+
1940
+ // src/validation/index.ts
1941
+ var validateDouyinParams = (methodType, params) => {
1942
+ const schema = DouyinValidationSchemas2[methodType];
1943
+ const validated = schema.parse(
1944
+ typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
1945
+ );
1946
+ return validated;
1947
+ };
1948
+ var validateBilibiliParams = (methodType, params) => {
1949
+ const schema = BilibiliValidationSchemas2[methodType];
1950
+ const validated = schema.parse(
1951
+ typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
1952
+ );
1953
+ return validated;
1954
+ };
1955
+ var validateKuaishouParams = (methodType, params) => {
1956
+ const schema = KuaishouValidationSchemas2[methodType];
1957
+ const validated = schema.parse(
1958
+ typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
1959
+ );
1960
+ return validated;
1961
+ };
1962
+ var createSuccessResponse = (data2, message, code = 200) => {
1963
+ return {
1964
+ success: true,
1965
+ data: data2,
1966
+ message,
1967
+ code,
1968
+ error: void 0
1969
+ };
1970
+ };
1971
+ var createErrorResponse = (error, message, code = 500) => {
1972
+ return {
1973
+ success: false,
1974
+ error,
1975
+ message,
1976
+ code,
1977
+ data: void 0
1978
+ };
1979
+ };
1980
+
1981
+ // src/model/DataFetchers.ts
1982
+ async function getDouyinData(methodType, optionsOrCookie, cookieOrOptions) {
1983
+ try {
1984
+ let options;
1985
+ let cookie;
1986
+ if (typeof optionsOrCookie === "string") {
1987
+ cookie = optionsOrCookie;
1988
+ options = cookieOrOptions;
1989
+ } else {
1990
+ options = optionsOrCookie;
1991
+ cookie = cookieOrOptions;
1992
+ }
1993
+ const { typeMode: _, ...validationOptions } = options || {};
1994
+ const validatedParams = validateDouyinParams(methodType, validationOptions);
1995
+ const apiParams = {
1996
+ ...validatedParams
1997
+ };
1998
+ const rawData = await DouyinData(apiParams, cookie);
1999
+ if (rawData.data === "") {
2000
+ return createErrorResponse(rawData.amagiError, "\u6296\u97F3\u6570\u636E\u83B7\u53D6\u5931\u8D25");
2001
+ }
2002
+ return createSuccessResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
2003
+ } catch (error) {
2004
+ const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
2005
+ throw new Error(`\u6296\u97F3\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
2006
+ }
2007
+ }
2008
+ async function getBilibiliData(methodType, optionsOrCookie, cookieOrOptions) {
2009
+ try {
2010
+ let options;
2011
+ let cookie;
2012
+ if (typeof optionsOrCookie === "string") {
2013
+ cookie = optionsOrCookie;
2014
+ options = cookieOrOptions;
2015
+ } else {
2016
+ options = optionsOrCookie;
2017
+ cookie = cookieOrOptions;
2018
+ }
2019
+ const { typeMode: _, ...validationOptions } = options || {};
2020
+ const validatedParams = validateBilibiliParams(methodType, validationOptions);
2021
+ const apiParams = {
2022
+ ...validatedParams
2023
+ };
2024
+ const rawData = await fetchBilibili(apiParams, cookie);
2025
+ if (rawData.code !== 0) {
2026
+ return createErrorResponse(rawData.amagiError, "B\u7AD9\u6570\u636E\u83B7\u53D6\u5931\u8D25");
2027
+ }
2028
+ return createSuccessResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
2029
+ } catch (error) {
2030
+ const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
2031
+ throw new Error(`B\u7AD9\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
2032
+ }
2033
+ }
2034
+ async function getKuaishouData(methodType, optionsOrCookie, cookieOrOptions) {
2035
+ try {
2036
+ let options;
2037
+ let cookie;
2038
+ if (typeof optionsOrCookie === "string") {
2039
+ cookie = optionsOrCookie;
2040
+ options = cookieOrOptions;
2041
+ } else {
2042
+ options = optionsOrCookie;
2043
+ cookie = cookieOrOptions;
2044
+ }
2045
+ const { typeMode: _, ...validationOptions } = options || {};
2046
+ const validatedParams = validateKuaishouParams(methodType, validationOptions);
2047
+ const apiParams = {
2048
+ ...validatedParams
2049
+ };
2050
+ const rawData = await KuaishouData(apiParams, cookie);
2051
+ if (rawData.code && Object.values(kuaishouAPIErrorCode).includes(rawData.code)) {
2052
+ return createErrorResponse(rawData.amagiError, "\u5FEB\u624B\u6570\u636E\u83B7\u53D6\u5931\u8D25");
2053
+ }
2054
+ return createSuccessResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
2055
+ } catch (error) {
2056
+ const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
2057
+ throw new Error(`\u5FEB\u624B\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
2058
+ }
2059
+ }
2060
+
2061
+ // src/platform/bilibili/BilibiliApi.ts
2062
+ var createBilibiliApiMethod = (methodType) => {
2063
+ return async (options, cookie) => {
2064
+ return await getBilibiliData(methodType, options, cookie);
2065
+ };
2066
+ };
2067
+ var createBoundBilibiliApiMethod = (methodType, cookie) => {
2068
+ return async (options) => {
2069
+ return await getBilibiliData(methodType, options, cookie);
2070
+ };
2071
+ };
2072
+ var bilibili = {
2073
+ /**
2074
+ * 获取单个视频作品数据
2075
+ * @param options 请求参数,包含 bvid 和可选的 typeMode
2076
+ * @param cookie 有效的用户 Cookie
2077
+ * @returns 统一格式的API响应
2078
+ */
2079
+ getVideoInfo: createBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
2080
+ /**
2081
+ * 获取单个视频下载信息数据
2082
+ * @param options 请求参数,包含 avid, cid 和可选的 typeMode
2083
+ * @param cookie 有效的用户 Cookie
2084
+ * @returns 统一格式的API响应
2085
+ */
2086
+ getVideoStream: createBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
2087
+ /**
2088
+ * 获取评论数据
2089
+ * @param options 请求参数,包含 type, oid, 可选的 number, pn 和 typeMode
2090
+ * @param cookie 有效的用户 Cookie
2091
+ * @returns 统一格式的API响应
2092
+ */
2093
+ getComments: createBilibiliApiMethod("\u8BC4\u8BBA\u6570\u636E"),
2094
+ /**
2095
+ * 获取用户主页数据
2096
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2097
+ * @param cookie 有效的用户 Cookie
2098
+ * @returns 统一格式的API响应
2099
+ */
2100
+ getUserProfile: createBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E"),
2101
+ /**
2102
+ * 获取用户主页动态列表数据
2103
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2104
+ * @param cookie 有效的用户 Cookie
2105
+ * @returns 统一格式的API响应
2106
+ */
2107
+ getUserDynamic: createBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E"),
2108
+ /**
2109
+ * 获取 Emoji 数据
2110
+ * @param options 可选的请求参数 (主要用于 typeMode)
2111
+ * @param cookie 有效的用户 Cookie
2112
+ * @returns 统一格式的API响应
2113
+ */
2114
+ getEmojiList: createBilibiliApiMethod("Emoji\u6570\u636E"),
2115
+ /**
2116
+ * 获取番剧基本信息数据
2117
+ * @param options 请求参数,包含可选的 season_id, ep_id 和 typeMode
2118
+ * @param cookie 有效的用户 Cookie
2119
+ * @returns 统一格式的API响应
2120
+ */
2121
+ getBangumiInfo: createBilibiliApiMethod("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E"),
2122
+ /**
2123
+ * 获取番剧下载信息数据
2124
+ * @param options 请求参数,包含 cid, ep_id 和可选的 typeMode
2125
+ * @param cookie 有效的用户 Cookie
2126
+ * @returns 统一格式的API响应
2127
+ */
2128
+ getBangumiStream: createBilibiliApiMethod("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
2129
+ /**
2130
+ * 获取动态详情数据
2131
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
2132
+ * @param cookie 有效的用户 Cookie
2133
+ * @returns 统一格式的API响应
2134
+ */
2135
+ getDynamicInfo: createBilibiliApiMethod("\u52A8\u6001\u8BE6\u60C5\u6570\u636E"),
2136
+ /**
2137
+ * 获取动态卡片数据
2138
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
2139
+ * @param cookie 有效的用户 Cookie
2140
+ * @returns 统一格式的API响应
2141
+ */
2142
+ getDynamicCard: createBilibiliApiMethod("\u52A8\u6001\u5361\u7247\u6570\u636E"),
2143
+ /**
2144
+ * 获取直播间信息
2145
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
2146
+ * @param cookie 有效的用户 Cookie
2147
+ * @returns 统一格式的API响应
2148
+ */
2149
+ getLiveRoomDetail: createBilibiliApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F"),
2150
+ /**
2151
+ * 获取直播间初始化信息
2152
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
2153
+ * @param cookie 有效的用户 Cookie
2154
+ * @returns 统一格式的API响应
2155
+ */
2156
+ getLiveRoomInitInfo: createBilibiliApiMethod("\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"),
2157
+ /**
2158
+ * 获取登录基本信息
2159
+ * @param options 可选的请求参数 (主要用于 typeMode)
2160
+ * @param cookie 有效的用户 Cookie
2161
+ * @returns 统一格式的API响应
2162
+ */
2163
+ getLoginBasicInfo: createBilibiliApiMethod("\u767B\u5F55\u57FA\u672C\u4FE1\u606F"),
2164
+ /**
2165
+ * 申请登录二维码
2166
+ * @param options 可选的请求参数 (主要用于 typeMode)
2167
+ * @param cookie 有效的用户 Cookie
2168
+ * @returns 统一格式的API响应
2169
+ */
2170
+ getLoginQrcode: createBilibiliApiMethod("\u7533\u8BF7\u4E8C\u7EF4\u7801"),
2171
+ /**
2172
+ * 检查二维码状态
2173
+ * @param options 请求参数,包含 qrcode_key 和可选的 typeMode
2174
+ * @param cookie 有效的用户 Cookie
2175
+ * @returns 统一格式的API响应
2176
+ */
2177
+ checkQrcodeStatus: createBilibiliApiMethod("\u4E8C\u7EF4\u7801\u72B6\u6001"),
2178
+ /**
2179
+ * 获取 UP 主总播放量
2180
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2181
+ * @param cookie 有效的用户 Cookie
2182
+ * @returns 统一格式的API响应
2183
+ */
2184
+ getUserTotalPlayCount: createBilibiliApiMethod("\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF"),
2185
+ /**
2186
+ * 将 AV 号转换为 BV 号
2187
+ * @param options 请求参数,包含 avid 和可选的 typeMode
2188
+ * @param cookie 有效的用户 Cookie (此接口通常不需要)
2189
+ * @returns 统一格式的API响应
2190
+ */
2191
+ convertAvToBv: createBilibiliApiMethod("AV\u8F6CBV"),
2192
+ /**
2193
+ * 将 BV 号转换为 AV 号
2194
+ * @param options 请求参数,包含 bvid 和可选的 typeMode
2195
+ * @param cookie 有效的用户 Cookie (此接口通常不需要)
2196
+ * @returns 统一格式的API响应
2197
+ */
2198
+ convertBvToAv: createBilibiliApiMethod("BV\u8F6CAV")
2199
+ };
2200
+ var createBoundBilibiliApi = (cookie) => {
2201
+ return {
2202
+ /**
2203
+ * 获取单个视频作品数据
2204
+ * @param options 请求参数,包含 bvid 和可选的 typeMode
2205
+ * @returns 统一格式的API响应
2206
+ */
2207
+ getVideoInfo: createBoundBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie),
2208
+ /**
2209
+ * 获取单个视频下载信息数据
2210
+ * @param options 请求参数,包含 avid, cid 和可选的 typeMode
2211
+ * @returns 统一格式的API响应
2212
+ */
2213
+ getVideoStream: createBoundBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", cookie),
2214
+ /**
2215
+ * 获取评论数据
2216
+ * @param options 请求参数,包含 type, oid, 可选的 number, pn 和 typeMode
2217
+ * @returns 统一格式的API响应
2218
+ */
2219
+ getComments: createBoundBilibiliApiMethod("\u8BC4\u8BBA\u6570\u636E", cookie),
2220
+ /**
2221
+ * 获取用户主页数据
2222
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2223
+ * @returns 统一格式的API响应
2224
+ */
2225
+ getUserProfile: createBoundBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E", cookie),
2226
+ /**
2227
+ * 获取用户主页动态列表数据
2228
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2229
+ * @returns 统一格式的API响应
2230
+ */
2231
+ getUserDynamic: createBoundBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E", cookie),
2232
+ /**
2233
+ * 获取 Emoji 数据
2234
+ * @param options 可选的请求参数 (主要用于 typeMode)
2235
+ * @returns 统一格式的API响应
2236
+ */
2237
+ getEmojiList: createBoundBilibiliApiMethod("Emoji\u6570\u636E", cookie),
2238
+ /**
2239
+ * 获取番剧基本信息数据
2240
+ * @param options 请求参数,包含可选的 season_id, ep_id 和 typeMode
2241
+ * @returns 统一格式的API响应
2242
+ */
2243
+ getBangumiInfo: createBoundBilibiliApiMethod("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E", cookie),
2244
+ /**
2245
+ * 获取番剧下载信息数据
2246
+ * @param options 请求参数,包含 cid, ep_id 和可选的 typeMode
2247
+ * @returns 统一格式的API响应
2248
+ */
2249
+ getBangumiStream: createBoundBilibiliApiMethod("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", cookie),
2250
+ /**
2251
+ * 获取动态详情数据
2252
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
2253
+ * @returns 统一格式的API响应
2254
+ */
2255
+ getDynamicInfo: createBoundBilibiliApiMethod("\u52A8\u6001\u8BE6\u60C5\u6570\u636E", cookie),
2256
+ /**
2257
+ * 获取动态卡片数据
2258
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
2259
+ * @returns 统一格式的API响应
2260
+ */
2261
+ getDynamicCard: createBoundBilibiliApiMethod("\u52A8\u6001\u5361\u7247\u6570\u636E", cookie),
2262
+ /**
2263
+ * 获取直播间信息
2264
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
2265
+ * @returns 统一格式的API响应
2266
+ */
2267
+ getLiveRoomDetail: createBoundBilibiliApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F", cookie),
2268
+ /**
2269
+ * 获取直播间初始化信息
2270
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
2271
+ * @returns 统一格式的API响应
2272
+ */
2273
+ getLiveRoomInitInfo: createBoundBilibiliApiMethod("\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F", cookie),
2274
+ /**
2275
+ * 获取登录基本信息
2276
+ * @param options 可选的请求参数 (主要用于 typeMode)
2277
+ * @returns 统一格式的API响应
2278
+ */
2279
+ getLoginBasicInfo: createBoundBilibiliApiMethod("\u767B\u5F55\u57FA\u672C\u4FE1\u606F", cookie),
2280
+ /**
2281
+ * 申请登录二维码
2282
+ * @param options 可选的请求参数 (主要用于 typeMode)
2283
+ * @returns 统一格式的API响应
2284
+ */
2285
+ getLoginQrcode: createBoundBilibiliApiMethod("\u7533\u8BF7\u4E8C\u7EF4\u7801", cookie),
2286
+ /**
2287
+ * 检查二维码状态
2288
+ * @param options 请求参数,包含 qrcode_key 和可选的 typeMode
2289
+ * @returns 统一格式的API响应
2290
+ */
2291
+ checkQrcodeStatus: createBoundBilibiliApiMethod("\u4E8C\u7EF4\u7801\u72B6\u6001", cookie),
2292
+ /**
2293
+ * 获取 UP 主总播放量
2294
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2295
+ * @returns 统一格式的API响应
2296
+ */
2297
+ getUserTotalPlayCount: createBoundBilibiliApiMethod("\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF", cookie),
2298
+ /**
2299
+ * 将 AV 号转换为 BV 号
2300
+ * @param options 请求参数,包含 avid 和可选的 typeMode
2301
+ * @returns 统一格式的API响应
2302
+ */
2303
+ convertAvToBv: createBoundBilibiliApiMethod("AV\u8F6CBV", cookie),
2304
+ /**
2305
+ * 将 BV 号转换为 AV 号
2306
+ * @param options 请求参数,包含 bvid 和可选的 typeMode
2307
+ * @returns 统一格式的API响应
2308
+ */
2309
+ convertBvToAv: createBoundBilibiliApiMethod("BV\u8F6CAV", cookie)
2310
+ };
2311
+ };
2312
+ var ApiError = class extends Error {
2313
+ code;
2314
+ platform;
2315
+ /**
2316
+ * 构造API错误
2317
+ * @param message - 错误消息
2318
+ * @param code - 错误代码
2319
+ * @param platform - 平台名称
2320
+ */
2321
+ constructor(message, code = 500, platform = "unknown") {
2322
+ super(message);
2323
+ this.name = "ApiError";
2324
+ this.code = code;
2325
+ this.platform = platform;
2326
+ }
2327
+ };
2328
+ var ValidationError = class _ValidationError extends Error {
2329
+ errors;
2330
+ requestPath;
2331
+ /**
2332
+ * 构造参数验证错误
2333
+ * @param message - 错误消息
2334
+ * @param errors - 详细错误信息
2335
+ * @param requestPath - HTTP请求路径
2336
+ */
2337
+ constructor(message, errors, requestPath) {
2338
+ super(message);
2339
+ this.name = "ValidationError";
2340
+ this.errors = errors;
2341
+ this.requestPath = requestPath;
2342
+ }
2343
+ /**
2344
+ * 从Zod错误创建验证错误
2345
+ * @param zodError - Zod验证错误
2346
+ * @param requestPath - HTTP请求路径
2347
+ * @returns 验证错误实例
2348
+ */
2349
+ static fromZodError(zodError, requestPath) {
2350
+ const errors = zodError.errors.map((err) => ({
2351
+ field: err.path.join("."),
2352
+ message: err.message
2353
+ }));
2354
+ return new _ValidationError("\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25", errors, requestPath);
2355
+ }
2356
+ };
2357
+ var handleError = (error, requestPath) => {
2358
+ if (error instanceof ValidationError) {
2336
2359
  return {
2337
- code: "UNKNOWN_ERROR" /* UNKNOWN */,
2360
+ code: 400,
2361
+ message: error.message,
2338
2362
  data: null,
2339
- amagiError: {
2340
- errorDescription: "\u672A\u77E5\u9519\u8BEF",
2341
- requestType: options.methodType,
2342
- requestUrl: options.url
2343
- },
2344
- amagiMessage: warningMessage
2363
+ errors: error.errors,
2364
+ requestPath: error.requestPath || requestPath
2345
2365
  };
2346
2366
  }
2347
- };
2348
-
2349
- // src/model/DataFetchers.ts
2350
- async function getDouyinData(methodType, optionsOrCookie, cookieOrOptions) {
2351
- try {
2352
- let options;
2353
- let cookie;
2354
- if (typeof optionsOrCookie === "string") {
2355
- cookie = optionsOrCookie;
2356
- options = cookieOrOptions;
2357
- } else {
2358
- options = optionsOrCookie;
2359
- cookie = cookieOrOptions;
2360
- }
2361
- const { typeMode: _, ...validationOptions } = options || {};
2362
- const validatedParams = validateDouyinParams(methodType, validationOptions);
2363
- const apiParams = {
2364
- ...validatedParams
2367
+ if (error instanceof ApiError) {
2368
+ return {
2369
+ code: error.code,
2370
+ message: error.message,
2371
+ data: null,
2372
+ platform: error.platform,
2373
+ requestPath
2365
2374
  };
2366
- const rawData = await DouyinData(apiParams, cookie);
2367
- return createApiResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
2368
- } catch (error) {
2369
- const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
2370
- throw new Error(`\u6296\u97F3\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
2371
2375
  }
2372
- }
2373
- async function getBilibiliData(methodType, optionsOrCookie, cookieOrOptions) {
2374
- try {
2375
- let options;
2376
- let cookie;
2377
- if (typeof optionsOrCookie === "string") {
2378
- cookie = optionsOrCookie;
2379
- options = cookieOrOptions;
2380
- } else {
2381
- options = optionsOrCookie;
2382
- cookie = cookieOrOptions;
2383
- }
2384
- const { typeMode: _, ...validationOptions } = options || {};
2385
- const validatedParams = validateBilibiliParams(methodType, validationOptions);
2386
- const apiParams = {
2387
- ...validatedParams
2388
- };
2389
- const rawData = await fetchBilibili(apiParams, cookie);
2390
- return createApiResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
2391
- } catch (error) {
2392
- const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
2393
- throw new Error(`B\u7AD9\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
2376
+ if (error instanceof z.ZodError) {
2377
+ const validationError = ValidationError.fromZodError(error, requestPath);
2378
+ return handleError(validationError, requestPath);
2394
2379
  }
2395
- }
2396
- async function getKuaishouData(methodType, optionsOrCookie, cookieOrOptions) {
2397
- try {
2398
- let options;
2399
- let cookie;
2400
- if (typeof optionsOrCookie === "string") {
2401
- cookie = optionsOrCookie;
2402
- options = cookieOrOptions;
2403
- } else {
2404
- options = optionsOrCookie;
2405
- cookie = cookieOrOptions;
2380
+ const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
2381
+ return {
2382
+ code: 500,
2383
+ message: errorMessage,
2384
+ data: null,
2385
+ requestPath
2386
+ };
2387
+ };
2388
+
2389
+ // src/middleware/validation.ts
2390
+ var createValidationMiddleware = (validateFn, methodType) => {
2391
+ return (req, res, next) => {
2392
+ try {
2393
+ const params = { ...req.query, ...req.body };
2394
+ const validatedParams = validateFn(methodType, params);
2395
+ req.validatedParams = validatedParams;
2396
+ next();
2397
+ } catch (error) {
2398
+ const errorResponse = handleError(error, req.originalUrl);
2399
+ res.status(errorResponse.code || 500).json(errorResponse);
2406
2400
  }
2407
- const { typeMode: _, ...validationOptions } = options || {};
2408
- const validatedParams = validateKuaishouParams(methodType, validationOptions);
2409
- const apiParams = {
2410
- ...validatedParams
2411
- };
2412
- const rawData = await KuaishouData(apiParams, cookie);
2413
- return createApiResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
2414
- } catch (error) {
2415
- const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
2416
- throw new Error(`\u5FEB\u624B\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
2417
- }
2418
- }
2401
+ };
2402
+ };
2403
+ var createDouyinValidationMiddleware = (methodType) => createValidationMiddleware(validateDouyinParams, methodType);
2404
+ var createBilibiliValidationMiddleware = (methodType) => createValidationMiddleware(validateBilibiliParams, methodType);
2405
+ var createKuaishouValidationMiddleware = (methodType) => createValidationMiddleware(validateKuaishouParams, methodType);
2419
2406
  var createBilibiliRouteHandler = (dataFetcher, methodType, cookie) => {
2420
2407
  return async (req, res) => {
2421
2408
  try {
@@ -2540,232 +2527,203 @@ var bilibiliUtils = {
2540
2527
  };
2541
2528
 
2542
2529
  // src/platform/douyin/DouyinApi.ts
2530
+ var createDouyinApiMethod = (methodType) => {
2531
+ return async (options, cookie) => {
2532
+ return await getDouyinData(methodType, options, cookie);
2533
+ };
2534
+ };
2535
+ var createBoundDouyinApiMethod = (methodType, cookie) => {
2536
+ return async (options) => {
2537
+ return await getDouyinData(methodType, options, cookie);
2538
+ };
2539
+ };
2543
2540
  var douyin = {
2544
2541
  /**
2545
2542
  * 聚合解析 (视频/图集/合辑)
2546
2543
  * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2547
2544
  * @param cookie 有效的用户 Cookie
2548
- * @returns 统一格式的API响应
2545
+ * @returns 统一格式的API响应,包含视频、图集或合辑数据
2549
2546
  */
2550
- getWorkInfo: async (options, cookie) => {
2551
- try {
2552
- const { typeMode, ...restOptions } = options;
2553
- const data2 = await DouyinData({ ...restOptions, methodType: "\u805A\u5408\u89E3\u6790" }, cookie);
2554
- return createApiResponse(data2, "\u83B7\u53D6\u805A\u5408\u89E3\u6790\u6570\u636E\u6210\u529F", 200);
2555
- } catch (error) {
2556
- return createApiResponse(null, `\u83B7\u53D6\u805A\u5408\u89E3\u6790\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2557
- }
2558
- },
2547
+ getWorkInfo: createDouyinApiMethod("\u805A\u5408\u89E3\u6790"),
2559
2548
  /**
2560
2549
  * 获取视频作品数据
2561
2550
  * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2562
2551
  * @param cookie 有效的用户 Cookie
2563
- * @returns 统一格式的API响应
2552
+ * @returns 统一格式的API响应,包含视频作品详细信息
2564
2553
  */
2565
- getVideoWorkInfo: async (options, cookie) => {
2566
- try {
2567
- const { typeMode, ...restOptions } = options;
2568
- const data2 = await DouyinData({ ...restOptions, methodType: "\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
2569
- return createApiResponse(data2, "\u83B7\u53D6\u89C6\u9891\u4F5C\u54C1\u6570\u636E\u6210\u529F", 200);
2570
- } catch (error) {
2571
- return createApiResponse(null, `\u83B7\u53D6\u89C6\u9891\u4F5C\u54C1\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2572
- }
2573
- },
2554
+ getVideoWorkInfo: createDouyinApiMethod("\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
2574
2555
  /**
2575
2556
  * 获取图集作品数据
2576
2557
  * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2577
2558
  * @param cookie 有效的用户 Cookie
2578
- * @returns 统一格式的API响应
2559
+ * @returns 统一格式的API响应,包含图集作品详细信息
2579
2560
  */
2580
- getImageAlbumWorkInfo: async (options, cookie) => {
2581
- try {
2582
- const { typeMode, ...restOptions } = options;
2583
- const data2 = await DouyinData({ ...restOptions, methodType: "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" }, cookie);
2584
- return createApiResponse(data2, "\u83B7\u53D6\u56FE\u96C6\u4F5C\u54C1\u6570\u636E\u6210\u529F", 200);
2585
- } catch (error) {
2586
- return createApiResponse(null, `\u83B7\u53D6\u56FE\u96C6\u4F5C\u54C1\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2587
- }
2588
- },
2561
+ getImageAlbumWorkInfo: createDouyinApiMethod("\u56FE\u96C6\u4F5C\u54C1\u6570\u636E"),
2589
2562
  /**
2590
2563
  * 获取合辑作品数据
2591
2564
  * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2592
2565
  * @param cookie 有效的用户 Cookie
2593
- * @returns 统一格式的API响应
2566
+ * @returns 统一格式的API响应,包含合辑作品详细信息
2594
2567
  */
2595
- getSlidesWorkInfo: async (options, cookie) => {
2596
- try {
2597
- const { typeMode, ...restOptions } = options;
2598
- const data2 = await DouyinData({ ...restOptions, methodType: "\u5408\u8F91\u4F5C\u54C1\u6570\u636E" }, cookie);
2599
- return createApiResponse(data2, "\u83B7\u53D6\u5408\u8F91\u4F5C\u54C1\u6570\u636E\u6210\u529F", 200);
2600
- } catch (error) {
2601
- return createApiResponse(null, `\u83B7\u53D6\u5408\u8F91\u4F5C\u54C1\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2602
- }
2603
- },
2568
+ getSlidesWorkInfo: createDouyinApiMethod("\u5408\u8F91\u4F5C\u54C1\u6570\u636E"),
2604
2569
  /**
2605
2570
  * 获取评论数据
2606
2571
  * @param options 请求参数,包含 aweme_id, 可选的 number, cursor 和 typeMode
2607
2572
  * @param cookie 有效的用户 Cookie
2608
- * @returns 统一格式的API响应
2573
+ * @returns 统一格式的API响应,包含评论列表数据
2609
2574
  */
2610
- getComments: async (options, cookie) => {
2611
- try {
2612
- const { typeMode, ...restOptions } = options;
2613
- const data2 = await DouyinData({ ...restOptions, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
2614
- return createApiResponse(data2, "\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u6210\u529F", 200);
2615
- } catch (error) {
2616
- return createApiResponse(null, `\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2617
- }
2618
- },
2575
+ getComments: createDouyinApiMethod("\u8BC4\u8BBA\u6570\u636E"),
2619
2576
  /**
2620
2577
  * 获取指定评论回复数据
2621
2578
  * @param options 请求参数,包含 aweme_id, comment_id, 可选的 number, cursor 和 typeMode
2622
2579
  * @param cookie 有效的用户 Cookie
2623
- * @returns 统一格式的API响应
2580
+ * @returns 统一格式的API响应,包含评论回复数据
2624
2581
  */
2625
- getCommentReplies: async (options, cookie) => {
2626
- try {
2627
- const { typeMode, ...restOptions } = options;
2628
- const data2 = await DouyinData({ ...restOptions, methodType: "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E" }, cookie);
2629
- return createApiResponse(data2, "\u83B7\u53D6\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E\u6210\u529F", 200);
2630
- } catch (error) {
2631
- return createApiResponse(null, `\u83B7\u53D6\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2632
- }
2633
- },
2582
+ getCommentReplies: createDouyinApiMethod("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E"),
2634
2583
  /**
2635
2584
  * 获取用户主页数据
2636
2585
  * @param options 请求参数,包含 sec_uid 和可选的 typeMode
2637
2586
  * @param cookie 有效的用户 Cookie
2638
- * @returns 统一格式的API响应
2587
+ * @returns 统一格式的API响应,包含用户详细信息
2639
2588
  */
2640
- getUserProfile: async (options, cookie) => {
2641
- try {
2642
- const { typeMode, ...restOptions } = options;
2643
- const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u6570\u636E" }, cookie);
2644
- return createApiResponse(data2, "\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u6570\u636E\u6210\u529F", 200);
2645
- } catch (error) {
2646
- return createApiResponse(null, `\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2647
- }
2648
- },
2589
+ getUserProfile: createDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E"),
2649
2590
  /**
2650
2591
  * 获取 Emoji 数据
2651
2592
  * @param options 可选的请求参数 (主要用于 typeMode)
2652
2593
  * @param cookie 可选的用户 Cookie
2653
- * @returns 统一格式的API响应
2594
+ * @returns 统一格式的API响应,包含Emoji列表数据
2654
2595
  */
2655
- getEmojiList: async (options, cookie) => {
2656
- try {
2657
- const { typeMode, ...restOptions } = options;
2658
- const data2 = await DouyinData({ ...restOptions, methodType: "Emoji\u6570\u636E" }, cookie);
2659
- return createApiResponse(data2, "\u83B7\u53D6Emoji\u6570\u636E\u6210\u529F", 200);
2660
- } catch (error) {
2661
- return createApiResponse(null, `\u83B7\u53D6Emoji\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2662
- }
2663
- },
2596
+ getEmojiList: createDouyinApiMethod("Emoji\u6570\u636E"),
2664
2597
  /**
2665
2598
  * 获取动态表情数据
2666
2599
  * @param options 可选的请求参数 (主要用于 typeMode)
2667
2600
  * @param cookie 有效的用户 Cookie
2668
- * @returns 统一格式的API响应
2601
+ * @returns 统一格式的API响应,包含动态表情数据
2669
2602
  */
2670
- getEmojiProList: async (options, cookie) => {
2671
- try {
2672
- const { typeMode, ...restOptions } = options;
2673
- const data2 = await DouyinData({ ...restOptions, methodType: "\u52A8\u6001\u8868\u60C5\u6570\u636E" }, cookie);
2674
- return createApiResponse(data2, "\u83B7\u53D6\u52A8\u6001\u8868\u60C5\u6570\u636E\u6210\u529F", 200);
2675
- } catch (error) {
2676
- return createApiResponse(null, `\u83B7\u53D6\u52A8\u6001\u8868\u60C5\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2677
- }
2678
- },
2603
+ getEmojiProList: createDouyinApiMethod("\u52A8\u6001\u8868\u60C5\u6570\u636E"),
2679
2604
  /**
2680
2605
  * 获取用户主页视频列表数据
2681
2606
  * @param options 请求参数,包含 sec_uid, 可选的 number, max_cursor 和 typeMode
2682
2607
  * @param cookie 有效的用户 Cookie
2683
- * @returns 统一格式的API响应
2608
+ * @returns 统一格式的API响应,包含用户发布的视频列表
2684
2609
  */
2685
- getUserVideos: async (options, cookie) => {
2686
- try {
2687
- const { typeMode, ...restOptions } = options;
2688
- const data2 = await DouyinData({ ...restOptions, methodType: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" }, cookie);
2689
- return createApiResponse(data2, "\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E\u6210\u529F", 200);
2690
- } catch (error) {
2691
- return createApiResponse(null, `\u83B7\u53D6\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2692
- }
2693
- },
2610
+ getUserVideos: createDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E"),
2694
2611
  /**
2695
2612
  * 获取音乐数据
2696
2613
  * @param options 请求参数,包含 music_id 和可选的 typeMode
2697
2614
  * @param cookie 有效的用户 Cookie
2698
- * @returns 统一格式的API响应
2615
+ * @returns 统一格式的API响应,包含音乐详细信息
2699
2616
  */
2700
- getMusicInfo: async (options, cookie) => {
2701
- try {
2702
- const { typeMode, ...restOptions } = options;
2703
- const data2 = await DouyinData({ ...restOptions, methodType: "\u97F3\u4E50\u6570\u636E" }, cookie);
2704
- return createApiResponse(data2, "\u83B7\u53D6\u97F3\u4E50\u6570\u636E\u6210\u529F", 200);
2705
- } catch (error) {
2706
- return createApiResponse(null, `\u83B7\u53D6\u97F3\u4E50\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2707
- }
2708
- },
2617
+ getMusicInfo: createDouyinApiMethod("\u97F3\u4E50\u6570\u636E"),
2709
2618
  /**
2710
2619
  * 获取热点词数据
2711
2620
  * @param options 请求参数,包含 query, 可选的 number 和 typeMode
2712
2621
  * @param cookie 有效的用户 Cookie
2713
- * @returns 统一格式的API响应
2622
+ * @returns 统一格式的API响应,包含热点搜索词列表
2714
2623
  */
2715
- getSuggestWords: async (options, cookie) => {
2716
- try {
2717
- const { typeMode, ...restOptions } = options;
2718
- const data2 = await DouyinData({ ...restOptions, methodType: "\u70ED\u70B9\u8BCD\u6570\u636E" }, cookie);
2719
- return createApiResponse(data2, "\u83B7\u53D6\u70ED\u70B9\u8BCD\u6570\u636E\u6210\u529F", 200);
2720
- } catch (error) {
2721
- return createApiResponse(null, `\u83B7\u53D6\u70ED\u70B9\u8BCD\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2722
- }
2723
- },
2624
+ getSuggestWords: createDouyinApiMethod("\u70ED\u70B9\u8BCD\u6570\u636E"),
2724
2625
  /**
2725
2626
  * 获取搜索数据
2726
2627
  * @param options 请求参数,包含 query, 可选的 number, search_id, cursor 和 typeMode
2727
2628
  * @param cookie 有效的用户 Cookie
2728
- * @returns 统一格式的API响应
2629
+ * @returns 统一格式的API响应,包含搜索结果数据
2729
2630
  */
2730
- search: async (options, cookie) => {
2731
- try {
2732
- const { typeMode, ...restOptions } = options;
2733
- const data2 = await DouyinData({ ...restOptions, methodType: "\u641C\u7D22\u6570\u636E" }, cookie);
2734
- return createApiResponse(data2, "\u83B7\u53D6\u641C\u7D22\u6570\u636E\u6210\u529F", 200);
2735
- } catch (error) {
2736
- return createApiResponse(null, `\u83B7\u53D6\u641C\u7D22\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2737
- }
2738
- },
2631
+ search: createDouyinApiMethod("\u641C\u7D22\u6570\u636E"),
2739
2632
  /**
2740
2633
  * 获取直播间信息
2741
2634
  * @param options 请求参数,包含 sec_uid 和可选的 typeMode
2742
2635
  * @param cookie 有效的用户 Cookie
2743
- * @returns 统一格式的API响应
2744
- */
2745
- getLiveRoomInfo: async (options, cookie) => {
2746
- try {
2747
- const { typeMode, ...restOptions } = options;
2748
- const data2 = await DouyinData({ ...restOptions, methodType: "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E" }, cookie);
2749
- return createApiResponse(data2, "\u83B7\u53D6\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E\u6210\u529F", 200);
2750
- } catch (error) {
2751
- return createApiResponse(null, `\u83B7\u53D6\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2752
- }
2753
- },
2754
- /**
2755
- * 申请二维码数据
2756
- * @param options 请求参数,包含 verify_fp 和可选的 typeMode
2757
- * @param cookie 有效的用户 Cookie
2758
- * @returns 统一格式的API响应
2636
+ * @returns 统一格式的API响应,包含直播间详细信息
2759
2637
  */
2760
- getLoginQrcode: async (options, cookie) => {
2761
- try {
2762
- const { typeMode, ...restOptions } = options;
2763
- const data2 = await DouyinData({ ...restOptions, methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E" }, cookie);
2764
- return createApiResponse(data2, "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E\u6210\u529F", 200);
2765
- } catch (error) {
2766
- return createApiResponse(null, `\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2767
- }
2768
- }
2638
+ getLiveRoomInfo: createDouyinApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E")
2639
+ };
2640
+ var createBoundDouyinApi = (cookie) => {
2641
+ return {
2642
+ /**
2643
+ * 聚合解析 (视频/图集/合辑)
2644
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2645
+ * @returns 统一格式的API响应,包含视频、图集或合辑数据
2646
+ */
2647
+ getWorkInfo: createBoundDouyinApiMethod("\u805A\u5408\u89E3\u6790", cookie),
2648
+ /**
2649
+ * 获取视频作品数据
2650
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2651
+ * @returns 统一格式的API响应,包含视频作品详细信息
2652
+ */
2653
+ getVideoWorkInfo: createBoundDouyinApiMethod("\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie),
2654
+ /**
2655
+ * 获取图集作品数据
2656
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2657
+ * @returns 统一格式的API响应,包含图集作品详细信息
2658
+ */
2659
+ getImageAlbumWorkInfo: createBoundDouyinApiMethod("\u56FE\u96C6\u4F5C\u54C1\u6570\u636E", cookie),
2660
+ /**
2661
+ * 获取合辑作品数据
2662
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2663
+ * @returns 统一格式的API响应,包含合辑作品详细信息
2664
+ */
2665
+ getSlidesWorkInfo: createBoundDouyinApiMethod("\u5408\u8F91\u4F5C\u54C1\u6570\u636E", cookie),
2666
+ /**
2667
+ * 获取评论数据
2668
+ * @param options 请求参数,包含 aweme_id, 可选的 number, cursor 和 typeMode
2669
+ * @returns 统一格式的API响应,包含评论列表数据
2670
+ */
2671
+ getComments: createBoundDouyinApiMethod("\u8BC4\u8BBA\u6570\u636E", cookie),
2672
+ /**
2673
+ * 获取指定评论回复数据
2674
+ * @param options 请求参数,包含 aweme_id, comment_id, 可选的 number, cursor 和 typeMode
2675
+ * @returns 统一格式的API响应,包含评论回复数据
2676
+ */
2677
+ getCommentReplies: createBoundDouyinApiMethod("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E", cookie),
2678
+ /**
2679
+ * 获取用户主页数据
2680
+ * @param options 请求参数,包含 sec_uid 和可选的 typeMode
2681
+ * @returns 统一格式的API响应,包含用户详细信息
2682
+ */
2683
+ getUserProfile: createBoundDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E", cookie),
2684
+ /**
2685
+ * 获取 Emoji 数据
2686
+ * @param options 可选的请求参数 (主要用于 typeMode)
2687
+ * @returns 统一格式的API响应,包含Emoji列表数据
2688
+ */
2689
+ getEmojiList: createBoundDouyinApiMethod("Emoji\u6570\u636E", cookie),
2690
+ /**
2691
+ * 获取动态表情数据
2692
+ * @param options 可选的请求参数 (主要用于 typeMode)
2693
+ * @returns 统一格式的API响应,包含动态表情数据
2694
+ */
2695
+ getEmojiProList: createBoundDouyinApiMethod("\u52A8\u6001\u8868\u60C5\u6570\u636E", cookie),
2696
+ /**
2697
+ * 获取用户主页视频列表数据
2698
+ * @param options 请求参数,包含 sec_uid, 可选的 number, max_cursor 和 typeMode
2699
+ * @returns 统一格式的API响应,包含用户发布的视频列表
2700
+ */
2701
+ getUserVideos: createBoundDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E", cookie),
2702
+ /**
2703
+ * 获取音乐数据
2704
+ * @param options 请求参数,包含 music_id 和可选的 typeMode
2705
+ * @returns 统一格式的API响应,包含音乐详细信息
2706
+ */
2707
+ getMusicInfo: createBoundDouyinApiMethod("\u97F3\u4E50\u6570\u636E", cookie),
2708
+ /**
2709
+ * 获取热点词数据
2710
+ * @param options 请求参数,包含 query, 可选的 number 和 typeMode
2711
+ * @returns 统一格式的API响应,包含热点搜索词列表
2712
+ */
2713
+ getSuggestWords: createBoundDouyinApiMethod("\u70ED\u70B9\u8BCD\u6570\u636E", cookie),
2714
+ /**
2715
+ * 获取搜索数据
2716
+ * @param options 请求参数,包含 query, 可选的 number, search_id, cursor 和 typeMode
2717
+ * @returns 统一格式的API响应,包含搜索结果数据
2718
+ */
2719
+ search: createBoundDouyinApiMethod("\u641C\u7D22\u6570\u636E", cookie),
2720
+ /**
2721
+ * 获取直播间信息
2722
+ * @param options 请求参数,包含 sec_uid 和可选的 typeMode
2723
+ * @returns 统一格式的API响应,包含直播间详细信息
2724
+ */
2725
+ getLiveRoomInfo: createBoundDouyinApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E", cookie)
2726
+ };
2769
2727
  };
2770
2728
  var createDouyinRouteHandler = (dataFetcher, methodType, cookie) => {
2771
2729
  return async (req, res) => {
@@ -2903,6 +2861,16 @@ var createKuaishouRoutes = (cookie) => {
2903
2861
  };
2904
2862
 
2905
2863
  // src/platform/kuaishou/KuaishouApi.ts
2864
+ var createKuaishouApiMethod = (methodType) => {
2865
+ return async (options, cookie) => {
2866
+ return await getKuaishouData(methodType, options, cookie);
2867
+ };
2868
+ };
2869
+ var createBoundKuaishouApiMethod = (methodType, cookie) => {
2870
+ return async (options) => {
2871
+ return await getKuaishouData(methodType, options, cookie);
2872
+ };
2873
+ };
2906
2874
  var kuaishou = {
2907
2875
  /**
2908
2876
  * 获取单个视频作品数据
@@ -2910,42 +2878,43 @@ var kuaishou = {
2910
2878
  * @param cookie 可选的用户 Cookie
2911
2879
  * @returns 统一格式的API响应
2912
2880
  */
2913
- getWorkInfo: async (options, cookie) => {
2914
- try {
2915
- const data2 = await KuaishouData({ ...options, methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" }, cookie);
2916
- return createApiResponse(data2, "\u83B7\u53D6\u89C6\u9891\u4F5C\u54C1\u6570\u636E\u6210\u529F", 200);
2917
- } catch (error) {
2918
- return createApiResponse(null, `\u83B7\u53D6\u89C6\u9891\u4F5C\u54C1\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2919
- }
2920
- },
2881
+ getWorkInfo: createKuaishouApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
2921
2882
  /**
2922
2883
  * 获取评论数据
2923
2884
  * @param options 请求参数,包含 photoId 和可选的 typeMode
2924
2885
  * @param cookie 可选的用户 Cookie
2925
2886
  * @returns 统一格式的API响应
2926
2887
  */
2927
- getComments: async (options, cookie) => {
2928
- try {
2929
- const data2 = await KuaishouData({ ...options, methodType: "\u8BC4\u8BBA\u6570\u636E" }, cookie);
2930
- return createApiResponse(data2, "\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u6210\u529F", 200);
2931
- } catch (error) {
2932
- return createApiResponse(null, `\u83B7\u53D6\u8BC4\u8BBA\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2933
- }
2934
- },
2888
+ getComments: createKuaishouApiMethod("\u8BC4\u8BBA\u6570\u636E"),
2935
2889
  /**
2936
2890
  * 获取 Emoji 数据
2937
2891
  * @param options 可选的请求参数 (主要用于 typeMode)
2938
2892
  * @param cookie 可选的用户 Cookie
2939
2893
  * @returns 统一格式的API响应
2940
2894
  */
2941
- getEmojiList: async (options, cookie) => {
2942
- try {
2943
- const data2 = await KuaishouData({ ...options, methodType: "Emoji\u6570\u636E" }, cookie);
2944
- return createApiResponse(data2, "\u83B7\u53D6Emoji\u6570\u636E\u6210\u529F", 200);
2945
- } catch (error) {
2946
- return createApiResponse(null, `\u83B7\u53D6Emoji\u6570\u636E\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`, 500);
2947
- }
2948
- }
2895
+ getEmojiList: createKuaishouApiMethod("Emoji\u6570\u636E")
2896
+ };
2897
+ var createBoundKuaishouApi = (cookie) => {
2898
+ return {
2899
+ /**
2900
+ * 获取单个视频作品数据
2901
+ * @param options 请求参数,包含 photoId 和可选的 typeMode
2902
+ * @returns 统一格式的API响应
2903
+ */
2904
+ getWorkInfo: createBoundKuaishouApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie),
2905
+ /**
2906
+ * 获取评论数据
2907
+ * @param options 请求参数,包含 photoId 和可选的 typeMode
2908
+ * @returns 统一格式的API响应
2909
+ */
2910
+ getComments: createBoundKuaishouApiMethod("\u8BC4\u8BBA\u6570\u636E", cookie),
2911
+ /**
2912
+ * 获取 Emoji 数据
2913
+ * @param options 可选的请求参数 (主要用于 typeMode)
2914
+ * @returns 统一格式的API响应
2915
+ */
2916
+ getEmojiList: createBoundKuaishouApiMethod("Emoji\u6570\u636E", cookie)
2917
+ };
2949
2918
  };
2950
2919
 
2951
2920
  // src/platform/kuaishou/index.ts
@@ -2999,15 +2968,15 @@ var fetchBilibiliData = getBilibiliData2;
2999
2968
  var fetchKuaishouData = getKuaishouData2;
3000
2969
  var v4CompatibilityMiddleware = (req, res, next) => {
3001
2970
  const originalJson = res.json;
3002
- res.json = function(data2) {
2971
+ res.json = (data2) => {
3003
2972
  if (data2 && typeof data2 === "object" && "data" in data2 && "message" in data2 && "code" in data2) {
3004
2973
  const v4Response = {
3005
2974
  ...data2.data,
3006
2975
  ...data2.requestPath && { requestPath: data2.requestPath }
3007
2976
  };
3008
- return originalJson.call(this, v4Response);
2977
+ return originalJson.call(void 0, v4Response);
3009
2978
  }
3010
- return originalJson.call(this, data2);
2979
+ return originalJson.call(void 0, data2);
3011
2980
  };
3012
2981
  next();
3013
2982
  };
@@ -3111,9 +3080,9 @@ var CreateApp = createAmagiClient;
3111
3080
  var Client = CreateApp;
3112
3081
  var amagi = Client;
3113
3082
  /*!
3114
- * @ikenxuan/amagi v4 (default)
3083
+ * @ikenxuan/amagi
3115
3084
  * Copyright(c) 2023 ikenxuan
3116
3085
  * GPL-3.0 Licensed
3117
3086
  */
3118
3087
 
3119
- export { CreateApp, KuaishouAPI, Networks, amagi, amagiClient, av2bv, bilibili, bilibiliAPI, bilibiliApiUrls, bilibiliErrorCodeMap, bilibiliUtils, bv2av, createBilibiliRoutes, createDouyinRoutes, createKuaishouRoutes, Client as default, douyin, douyinAPI, douyinApiUrls, douyinSign, douyinUtils, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData2 as getBilibiliData, getDouyinData2 as getDouyinData, getKuaishouData2 as getKuaishouData, httpLogger, kuaishou, kuaishouAPI, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, createDouyinRoutes as registerBilibiliRoutes, createBilibiliRoutes as registerDouyinRoutes, createKuaishouRoutes as registerKuaishouRoutes, wbi_sign };
3088
+ export { CreateApp, Networks, amagi, amagiClient, av2bv, bilibili, bilibiliApiUrls, bilibiliErrorCodeMap, bilibiliUtils, bv2av, createBilibiliRoutes, createBoundBilibiliApi, createBoundDouyinApi, createBoundKuaishouApi, createDouyinRoutes, createKuaishouRoutes, Client as default, douyin, douyinApiUrls, douyinSign, douyinUtils, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData2 as getBilibiliData, getDouyinData2 as getDouyinData, getKuaishouData2 as getKuaishouData, httpLogger, kuaishou, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, createDouyinRoutes as registerBilibiliRoutes, createBilibiliRoutes as registerDouyinRoutes, createKuaishouRoutes as registerKuaishouRoutes, wbi_sign };