@ikenxuan/amagi 4.4.20-pr117.f85bb30 → 4.5.0

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