@ikenxuan/amagi 4.4.20-pr117.f85bb30 → 4.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,727 +873,141 @@ 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;
1360
1008
  }
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");
1009
+ padHex(num, size) {
1010
+ return num.padStart(size, "0");
1591
1011
  }
1592
1012
  };
1593
1013
  function rc4_encrypt(plaintext, key) {
@@ -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,689 @@ 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 DouyinQrcodeParamsSchema = zod.z.object({
1825
+ methodType: zod.z.literal("\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E"),
1826
+ verify_fp: zod.z.string({ required_error: "fp\u6307\u7EB9\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "fp\u6307\u7EB9\u4E0D\u80FD\u4E3A\u7A7A")
1827
+ });
1828
+ var DouyinEmojiListParamsSchema = zod.z.object({
1829
+ methodType: zod.z.literal("Emoji\u6570\u636E")
1830
+ });
1831
+ var DouyinEmojiProParamsSchema = zod.z.object({
1832
+ methodType: zod.z.literal("\u52A8\u6001\u8868\u60C5\u6570\u636E")
1833
+ });
1834
+ var DouyinValidationSchemas2 = {
1835
+ "\u805A\u5408\u89E3\u6790": DouyinWorkParamsSchema,
1836
+ "\u89C6\u9891\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
1837
+ "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
1838
+ "\u5408\u8F91\u4F5C\u54C1\u6570\u636E": DouyinWorkParamsSchema,
1839
+ "\u8BC4\u8BBA\u6570\u636E": DouyinCommentParamsSchema,
1840
+ "\u7528\u6237\u4E3B\u9875\u6570\u636E": DouyinUserParamsSchema,
1841
+ "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E": DouyinUserParamsSchema,
1842
+ "\u70ED\u70B9\u8BCD\u6570\u636E": DouyinSearchParamsSchema,
1843
+ "\u641C\u7D22\u6570\u636E": DouyinSearchParamsSchema,
1844
+ "\u97F3\u4E50\u6570\u636E": DouyinMusicParamsSchema,
1845
+ "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E": DouyinUserParamsSchema,
1846
+ "\u7533\u8BF7\u4E8C\u7EF4\u7801\u6570\u636E": DouyinQrcodeParamsSchema,
1847
+ "Emoji\u6570\u636E": DouyinEmojiListParamsSchema,
1848
+ "\u52A8\u6001\u8868\u60C5\u6570\u636E": DouyinEmojiProParamsSchema,
1849
+ "\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E": DouyinCommentReplyParamsSchema
1850
+ };
1851
+ var BilibiliVideoParamsSchema = zod.z.object({
1852
+ methodType: zod.z.literal("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
1853
+ bvid: zod.z.string({ required_error: "BVID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "BVID\u4E0D\u80FD\u4E3A\u7A7A")
1854
+ });
1855
+ var BilibiliVideoDownloadParamsSchema = zod.z.object({
1856
+ methodType: zod.z.literal("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
1857
+ avid: smartNumber("AVID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
1858
+ cid: smartNumber("CID\u4E0D\u80FD\u4E3A\u7A7A", 1, true)
1859
+ });
1860
+ var BilibiliCommentParamsSchema = zod.z.object({
1861
+ methodType: zod.z.literal("\u8BC4\u8BBA\u6570\u636E"),
1862
+ oid: smartNumber("OID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
1863
+ type: smartNumber("\u8BC4\u8BBA\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A", 1, true).refine(
1864
+ (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),
1865
+ { message: "\u65E0\u6548\u7684\u8BC4\u8BBA\u533A\u7C7B\u578B" }
1866
+ ),
1867
+ number: zod.z.coerce.number().int().positive().default(20).optional(),
1868
+ pn: zod.z.coerce.number().int().positive().default(1).optional()
1869
+ });
1870
+ var BilibiliUserParamsSchema = zod.z.object({
1871
+ 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"]),
1872
+ host_mid: smartNumber("UP\u4E3BUID\u4E0D\u80FD\u4E3A\u7A7A", 1, true)
1873
+ });
1874
+ var BilibiliEmojiParamsSchema = zod.z.object({
1875
+ methodType: zod.z.literal("Emoji\u6570\u636E")
1876
+ });
1877
+ var BilibiliBangumiInfoParamsSchema = zod.z.object({
1878
+ methodType: zod.z.literal("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E"),
1879
+ ep_id: zod.z.string().min(1, "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A").optional(),
1880
+ season_id: zod.z.string().optional()
1881
+ }).refine(
1882
+ (data2) => data2.ep_id || data2.season_id,
1883
+ {
1884
+ message: "ep_id \u548C season_id \u81F3\u5C11\u9700\u8981\u63D0\u4F9B\u4E00\u4E2A",
1885
+ path: ["ep_id"]
1886
+ }
1887
+ );
1888
+ var BilibiliBangumiStreamParamsSchema = zod.z.object({
1889
+ methodType: zod.z.literal("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
1890
+ cid: smartNumber("CID\u4E0D\u80FD\u4E3A\u7A7A", 1, true),
1891
+ ep_id: zod.z.string({ required_error: "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u756A\u5267EP ID\u4E0D\u80FD\u4E3A\u7A7A")
1892
+ });
1893
+ var BilibiliDynamicParamsSchema = zod.z.object({
1894
+ methodType: zod.z.enum(["\u52A8\u6001\u8BE6\u60C5\u6570\u636E", "\u52A8\u6001\u5361\u7247\u6570\u636E"]),
1895
+ dynamic_id: zod.z.string({ required_error: "\u52A8\u6001ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u52A8\u6001ID\u4E0D\u80FD\u4E3A\u7A7A")
1896
+ });
1897
+ var BilibiliLiveParamsSchema = zod.z.object({
1898
+ methodType: zod.z.enum(["\u76F4\u64AD\u95F4\u4FE1\u606F", "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"]),
1899
+ room_id: zod.z.string({ required_error: "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u76F4\u64AD\u95F4ID\u4E0D\u80FD\u4E3A\u7A7A")
1900
+ });
1901
+ var BilibiliLoginParamsSchema = zod.z.object({
1902
+ methodType: zod.z.literal("\u767B\u5F55\u57FA\u672C\u4FE1\u606F")
1903
+ });
1904
+ var BilibiliQrcodeParamsSchema = zod.z.object({
1905
+ methodType: zod.z.literal("\u7533\u8BF7\u4E8C\u7EF4\u7801")
1906
+ });
1907
+ var BilibiliQrcodeStatusParamsSchema = zod.z.object({
1908
+ methodType: zod.z.literal("\u4E8C\u7EF4\u7801\u72B6\u6001"),
1909
+ qrcode_key: zod.z.string({ required_error: "\u4E8C\u7EF4\u7801key\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u4E8C\u7EF4\u7801key\u4E0D\u80FD\u4E3A\u7A7A")
1910
+ });
1911
+ var BilibiliAv2BvParamsSchema = zod.z.object({
1912
+ methodType: zod.z.literal("AV\u8F6CBV"),
1913
+ avid: zod.z.coerce.number({ required_error: "AVID\u4E0D\u80FD\u4E3A\u7A7A" }).int().positive()
1914
+ });
1915
+ var BilibiliBv2AvParamsSchema = zod.z.object({
1916
+ methodType: zod.z.literal("BV\u8F6CAV"),
1917
+ bvid: zod.z.string({ required_error: "BVID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "BVID\u4E0D\u80FD\u4E3A\u7A7A")
1918
+ });
1919
+ var BilibiliValidationSchemas2 = {
1920
+ "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": BilibiliVideoParamsSchema,
1921
+ "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": BilibiliVideoDownloadParamsSchema,
1922
+ "\u8BC4\u8BBA\u6570\u636E": BilibiliCommentParamsSchema,
1923
+ "\u7528\u6237\u4E3B\u9875\u6570\u636E": BilibiliUserParamsSchema,
1924
+ "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E": BilibiliUserParamsSchema,
1925
+ "Emoji\u6570\u636E": BilibiliEmojiParamsSchema,
1926
+ "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E": BilibiliBangumiInfoParamsSchema,
1927
+ "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E": BilibiliBangumiStreamParamsSchema,
1928
+ "\u52A8\u6001\u8BE6\u60C5\u6570\u636E": BilibiliDynamicParamsSchema,
1929
+ "\u52A8\u6001\u5361\u7247\u6570\u636E": BilibiliDynamicParamsSchema,
1930
+ "\u76F4\u64AD\u95F4\u4FE1\u606F": BilibiliLiveParamsSchema,
1931
+ "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F": BilibiliLiveParamsSchema,
1932
+ "\u767B\u5F55\u57FA\u672C\u4FE1\u606F": BilibiliLoginParamsSchema,
1933
+ "\u7533\u8BF7\u4E8C\u7EF4\u7801": BilibiliQrcodeParamsSchema,
1934
+ "\u4E8C\u7EF4\u7801\u72B6\u6001": BilibiliQrcodeStatusParamsSchema,
1935
+ "\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF": BilibiliUserParamsSchema,
1936
+ "AV\u8F6CBV": BilibiliAv2BvParamsSchema,
1937
+ "BV\u8F6CAV": BilibiliBv2AvParamsSchema
1938
+ };
1939
+ var KuaishouVideoParamsSchema = zod.z.object({
1940
+ methodType: zod.z.literal("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
1941
+ photoId: zod.z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A")
1942
+ });
1943
+ var KuaishouCommentParamsSchema = zod.z.object({
1944
+ methodType: zod.z.literal("\u8BC4\u8BBA\u6570\u636E"),
1945
+ photoId: zod.z.string({ required_error: "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A" }).min(1, "\u89C6\u9891ID\u4E0D\u80FD\u4E3A\u7A7A")
1946
+ });
1947
+ var KuaishouEmojiParamsSchema = zod.z.object({
1948
+ methodType: zod.z.literal("Emoji\u6570\u636E")
1949
+ });
1950
+ var KuaishouValidationSchemas2 = {
1951
+ "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E": KuaishouVideoParamsSchema,
1952
+ "\u8BC4\u8BBA\u6570\u636E": KuaishouCommentParamsSchema,
1953
+ "Emoji\u6570\u636E": KuaishouEmojiParamsSchema
1954
+ };
1955
+
1956
+ // src/validation/index.ts
1957
+ var validateDouyinParams = (methodType, params) => {
1958
+ const schema = DouyinValidationSchemas2[methodType];
1959
+ const validated = schema.parse(
1960
+ typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
1961
+ );
1962
+ return validated;
1963
+ };
1964
+ var validateBilibiliParams = (methodType, params) => {
1965
+ const schema = BilibiliValidationSchemas2[methodType];
1966
+ const validated = schema.parse(
1967
+ typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
1968
+ );
1969
+ return validated;
1970
+ };
1971
+ var validateKuaishouParams = (methodType, params) => {
1972
+ const schema = KuaishouValidationSchemas2[methodType];
1973
+ const validated = schema.parse(
1974
+ typeof params === "object" && params !== null ? { methodType, ...params } : { methodType, params }
1975
+ );
1976
+ return validated;
1977
+ };
1978
+ var createSuccessResponse = (data2, message, code = 200) => {
1979
+ return {
1980
+ success: true,
1981
+ data: data2,
1982
+ message,
1983
+ code,
1984
+ error: void 0
1985
+ };
1986
+ };
1987
+ var createErrorResponse = (error, message, code = 500) => {
1988
+ return {
1989
+ success: false,
1990
+ error,
1991
+ message,
1992
+ code,
1993
+ data: void 0
1994
+ };
1995
+ };
1996
+
1997
+ // src/model/DataFetchers.ts
1998
+ async function getDouyinData(methodType, optionsOrCookie, cookieOrOptions) {
1999
+ try {
2000
+ let options;
2001
+ let cookie;
2002
+ if (typeof optionsOrCookie === "string") {
2003
+ cookie = optionsOrCookie;
2004
+ options = cookieOrOptions;
2005
+ } else {
2006
+ options = optionsOrCookie;
2007
+ cookie = cookieOrOptions;
2008
+ }
2009
+ const { typeMode: _, ...validationOptions } = options || {};
2010
+ const validatedParams = validateDouyinParams(methodType, validationOptions);
2011
+ const apiParams = {
2012
+ ...validatedParams
2013
+ };
2014
+ const rawData = await DouyinData(apiParams, cookie);
2015
+ if (rawData.data === "") {
2016
+ return createErrorResponse(rawData.amagiError, "\u6296\u97F3\u6570\u636E\u83B7\u53D6\u5931\u8D25");
2017
+ }
2018
+ return createSuccessResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
2019
+ } catch (error) {
2020
+ const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
2021
+ throw new Error(`\u6296\u97F3\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
2022
+ }
2023
+ }
2024
+ async function getBilibiliData(methodType, optionsOrCookie, cookieOrOptions) {
2025
+ try {
2026
+ let options;
2027
+ let cookie;
2028
+ if (typeof optionsOrCookie === "string") {
2029
+ cookie = optionsOrCookie;
2030
+ options = cookieOrOptions;
2031
+ } else {
2032
+ options = optionsOrCookie;
2033
+ cookie = cookieOrOptions;
2034
+ }
2035
+ const { typeMode: _, ...validationOptions } = options || {};
2036
+ const validatedParams = validateBilibiliParams(methodType, validationOptions);
2037
+ const apiParams = {
2038
+ ...validatedParams
2039
+ };
2040
+ const rawData = await fetchBilibili(apiParams, cookie);
2041
+ if (rawData.code !== 0) {
2042
+ return createErrorResponse(rawData.amagiError, "B\u7AD9\u6570\u636E\u83B7\u53D6\u5931\u8D25");
2043
+ }
2044
+ return createSuccessResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
2045
+ } catch (error) {
2046
+ const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
2047
+ throw new Error(`B\u7AD9\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
2048
+ }
2049
+ }
2050
+ async function getKuaishouData(methodType, optionsOrCookie, cookieOrOptions) {
2051
+ try {
2052
+ let options;
2053
+ let cookie;
2054
+ if (typeof optionsOrCookie === "string") {
2055
+ cookie = optionsOrCookie;
2056
+ options = cookieOrOptions;
2057
+ } else {
2058
+ options = optionsOrCookie;
2059
+ cookie = cookieOrOptions;
2060
+ }
2061
+ const { typeMode: _, ...validationOptions } = options || {};
2062
+ const validatedParams = validateKuaishouParams(methodType, validationOptions);
2063
+ const apiParams = {
2064
+ ...validatedParams
2065
+ };
2066
+ const rawData = await KuaishouData(apiParams, cookie);
2067
+ if (rawData.code && Object.values(kuaishouAPIErrorCode).includes(rawData.code)) {
2068
+ return createErrorResponse(rawData.amagiError, "\u5FEB\u624B\u6570\u636E\u83B7\u53D6\u5931\u8D25");
2069
+ }
2070
+ return createSuccessResponse(rawData, "\u83B7\u53D6\u6210\u529F", 200);
2071
+ } catch (error) {
2072
+ const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
2073
+ throw new Error(`\u5FEB\u624B\u6570\u636E\u83B7\u53D6\u5931\u8D25: ${errorMessage}`);
2074
+ }
2075
+ }
2076
+
2077
+ // src/platform/bilibili/BilibiliApi.ts
2078
+ var createBilibiliApiMethod = (methodType) => {
2079
+ return async (options, cookie) => {
2080
+ return await getBilibiliData(methodType, options, cookie);
2081
+ };
2082
+ };
2083
+ var createBoundBilibiliApiMethod = (methodType, cookie) => {
2084
+ return async (options) => {
2085
+ return await getBilibiliData(methodType, options, cookie);
2086
+ };
2087
+ };
2088
+ var bilibili = {
2089
+ /**
2090
+ * 获取单个视频作品数据
2091
+ * @param options 请求参数,包含 bvid 和可选的 typeMode
2092
+ * @param cookie 有效的用户 Cookie
2093
+ * @returns 统一格式的API响应
2094
+ */
2095
+ getVideoInfo: createBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
2096
+ /**
2097
+ * 获取单个视频下载信息数据
2098
+ * @param options 请求参数,包含 avid, cid 和可选的 typeMode
2099
+ * @param cookie 有效的用户 Cookie
2100
+ * @returns 统一格式的API响应
2101
+ */
2102
+ getVideoStream: createBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
2103
+ /**
2104
+ * 获取评论数据
2105
+ * @param options 请求参数,包含 type, oid, 可选的 number, pn 和 typeMode
2106
+ * @param cookie 有效的用户 Cookie
2107
+ * @returns 统一格式的API响应
2108
+ */
2109
+ getComments: createBilibiliApiMethod("\u8BC4\u8BBA\u6570\u636E"),
2110
+ /**
2111
+ * 获取用户主页数据
2112
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2113
+ * @param cookie 有效的用户 Cookie
2114
+ * @returns 统一格式的API响应
2115
+ */
2116
+ getUserProfile: createBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E"),
2117
+ /**
2118
+ * 获取用户主页动态列表数据
2119
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2120
+ * @param cookie 有效的用户 Cookie
2121
+ * @returns 统一格式的API响应
2122
+ */
2123
+ getUserDynamic: createBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E"),
2124
+ /**
2125
+ * 获取 Emoji 数据
2126
+ * @param options 可选的请求参数 (主要用于 typeMode)
2127
+ * @param cookie 有效的用户 Cookie
2128
+ * @returns 统一格式的API响应
2129
+ */
2130
+ getEmojiList: createBilibiliApiMethod("Emoji\u6570\u636E"),
2131
+ /**
2132
+ * 获取番剧基本信息数据
2133
+ * @param options 请求参数,包含可选的 season_id, ep_id 和 typeMode
2134
+ * @param cookie 有效的用户 Cookie
2135
+ * @returns 统一格式的API响应
2136
+ */
2137
+ getBangumiInfo: createBilibiliApiMethod("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E"),
2138
+ /**
2139
+ * 获取番剧下载信息数据
2140
+ * @param options 请求参数,包含 cid, ep_id 和可选的 typeMode
2141
+ * @param cookie 有效的用户 Cookie
2142
+ * @returns 统一格式的API响应
2143
+ */
2144
+ getBangumiStream: createBilibiliApiMethod("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E"),
2145
+ /**
2146
+ * 获取动态详情数据
2147
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
2148
+ * @param cookie 有效的用户 Cookie
2149
+ * @returns 统一格式的API响应
2150
+ */
2151
+ getDynamicInfo: createBilibiliApiMethod("\u52A8\u6001\u8BE6\u60C5\u6570\u636E"),
2152
+ /**
2153
+ * 获取动态卡片数据
2154
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
2155
+ * @param cookie 有效的用户 Cookie
2156
+ * @returns 统一格式的API响应
2157
+ */
2158
+ getDynamicCard: createBilibiliApiMethod("\u52A8\u6001\u5361\u7247\u6570\u636E"),
2159
+ /**
2160
+ * 获取直播间信息
2161
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
2162
+ * @param cookie 有效的用户 Cookie
2163
+ * @returns 统一格式的API响应
2164
+ */
2165
+ getLiveRoomDetail: createBilibiliApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F"),
2166
+ /**
2167
+ * 获取直播间初始化信息
2168
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
2169
+ * @param cookie 有效的用户 Cookie
2170
+ * @returns 统一格式的API响应
2171
+ */
2172
+ getLiveRoomInitInfo: createBilibiliApiMethod("\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"),
2173
+ /**
2174
+ * 获取登录基本信息
2175
+ * @param options 可选的请求参数 (主要用于 typeMode)
2176
+ * @param cookie 有效的用户 Cookie
2177
+ * @returns 统一格式的API响应
2178
+ */
2179
+ getLoginBasicInfo: createBilibiliApiMethod("\u767B\u5F55\u57FA\u672C\u4FE1\u606F"),
2180
+ /**
2181
+ * 申请登录二维码
2182
+ * @param options 可选的请求参数 (主要用于 typeMode)
2183
+ * @param cookie 有效的用户 Cookie
2184
+ * @returns 统一格式的API响应
2185
+ */
2186
+ getLoginQrcode: createBilibiliApiMethod("\u7533\u8BF7\u4E8C\u7EF4\u7801"),
2187
+ /**
2188
+ * 检查二维码状态
2189
+ * @param options 请求参数,包含 qrcode_key 和可选的 typeMode
2190
+ * @param cookie 有效的用户 Cookie
2191
+ * @returns 统一格式的API响应
2192
+ */
2193
+ checkQrcodeStatus: createBilibiliApiMethod("\u4E8C\u7EF4\u7801\u72B6\u6001"),
2194
+ /**
2195
+ * 获取 UP 主总播放量
2196
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2197
+ * @param cookie 有效的用户 Cookie
2198
+ * @returns 统一格式的API响应
2199
+ */
2200
+ getUserTotalPlayCount: createBilibiliApiMethod("\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF"),
2201
+ /**
2202
+ * 将 AV 号转换为 BV 号
2203
+ * @param options 请求参数,包含 avid 和可选的 typeMode
2204
+ * @param cookie 有效的用户 Cookie (此接口通常不需要)
2205
+ * @returns 统一格式的API响应
2206
+ */
2207
+ convertAvToBv: createBilibiliApiMethod("AV\u8F6CBV"),
2208
+ /**
2209
+ * 将 BV 号转换为 AV 号
2210
+ * @param options 请求参数,包含 bvid 和可选的 typeMode
2211
+ * @param cookie 有效的用户 Cookie (此接口通常不需要)
2212
+ * @returns 统一格式的API响应
2213
+ */
2214
+ convertBvToAv: createBilibiliApiMethod("BV\u8F6CAV")
2215
+ };
2216
+ var createBoundBilibiliApi = (cookie) => {
2217
+ return {
2218
+ /**
2219
+ * 获取单个视频作品数据
2220
+ * @param options 请求参数,包含 bvid 和可选的 typeMode
2221
+ * @returns 统一格式的API响应
2222
+ */
2223
+ getVideoInfo: createBoundBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie),
2224
+ /**
2225
+ * 获取单个视频下载信息数据
2226
+ * @param options 请求参数,包含 avid, cid 和可选的 typeMode
2227
+ * @returns 统一格式的API响应
2228
+ */
2229
+ getVideoStream: createBoundBilibiliApiMethod("\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", cookie),
2230
+ /**
2231
+ * 获取评论数据
2232
+ * @param options 请求参数,包含 type, oid, 可选的 number, pn 和 typeMode
2233
+ * @returns 统一格式的API响应
2234
+ */
2235
+ getComments: createBoundBilibiliApiMethod("\u8BC4\u8BBA\u6570\u636E", cookie),
2236
+ /**
2237
+ * 获取用户主页数据
2238
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2239
+ * @returns 统一格式的API响应
2240
+ */
2241
+ getUserProfile: createBoundBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E", cookie),
2242
+ /**
2243
+ * 获取用户主页动态列表数据
2244
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2245
+ * @returns 统一格式的API响应
2246
+ */
2247
+ getUserDynamic: createBoundBilibiliApiMethod("\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E", cookie),
2248
+ /**
2249
+ * 获取 Emoji 数据
2250
+ * @param options 可选的请求参数 (主要用于 typeMode)
2251
+ * @returns 统一格式的API响应
2252
+ */
2253
+ getEmojiList: createBoundBilibiliApiMethod("Emoji\u6570\u636E", cookie),
2254
+ /**
2255
+ * 获取番剧基本信息数据
2256
+ * @param options 请求参数,包含可选的 season_id, ep_id 和 typeMode
2257
+ * @returns 统一格式的API响应
2258
+ */
2259
+ getBangumiInfo: createBoundBilibiliApiMethod("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E", cookie),
2260
+ /**
2261
+ * 获取番剧下载信息数据
2262
+ * @param options 请求参数,包含 cid, ep_id 和可选的 typeMode
2263
+ * @returns 统一格式的API响应
2264
+ */
2265
+ getBangumiStream: createBoundBilibiliApiMethod("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E", cookie),
2266
+ /**
2267
+ * 获取动态详情数据
2268
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
2269
+ * @returns 统一格式的API响应
2270
+ */
2271
+ getDynamicInfo: createBoundBilibiliApiMethod("\u52A8\u6001\u8BE6\u60C5\u6570\u636E", cookie),
2272
+ /**
2273
+ * 获取动态卡片数据
2274
+ * @param options 请求参数,包含 dynamic_id 和可选的 typeMode
2275
+ * @returns 统一格式的API响应
2276
+ */
2277
+ getDynamicCard: createBoundBilibiliApiMethod("\u52A8\u6001\u5361\u7247\u6570\u636E", cookie),
2278
+ /**
2279
+ * 获取直播间信息
2280
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
2281
+ * @returns 统一格式的API响应
2282
+ */
2283
+ getLiveRoomDetail: createBoundBilibiliApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F", cookie),
2284
+ /**
2285
+ * 获取直播间初始化信息
2286
+ * @param options 请求参数,包含 room_id 和可选的 typeMode
2287
+ * @returns 统一格式的API响应
2288
+ */
2289
+ getLiveRoomInitInfo: createBoundBilibiliApiMethod("\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F", cookie),
2290
+ /**
2291
+ * 获取登录基本信息
2292
+ * @param options 可选的请求参数 (主要用于 typeMode)
2293
+ * @returns 统一格式的API响应
2294
+ */
2295
+ getLoginBasicInfo: createBoundBilibiliApiMethod("\u767B\u5F55\u57FA\u672C\u4FE1\u606F", cookie),
2296
+ /**
2297
+ * 申请登录二维码
2298
+ * @param options 可选的请求参数 (主要用于 typeMode)
2299
+ * @returns 统一格式的API响应
2300
+ */
2301
+ getLoginQrcode: createBoundBilibiliApiMethod("\u7533\u8BF7\u4E8C\u7EF4\u7801", cookie),
2302
+ /**
2303
+ * 检查二维码状态
2304
+ * @param options 请求参数,包含 qrcode_key 和可选的 typeMode
2305
+ * @returns 统一格式的API响应
2306
+ */
2307
+ checkQrcodeStatus: createBoundBilibiliApiMethod("\u4E8C\u7EF4\u7801\u72B6\u6001", cookie),
2308
+ /**
2309
+ * 获取 UP 主总播放量
2310
+ * @param options 请求参数,包含 host_mid 和可选的 typeMode
2311
+ * @returns 统一格式的API响应
2312
+ */
2313
+ getUserTotalPlayCount: createBoundBilibiliApiMethod("\u83B7\u53D6UP\u4E3B\u603B\u64AD\u653E\u91CF", cookie),
2314
+ /**
2315
+ * 将 AV 号转换为 BV 号
2316
+ * @param options 请求参数,包含 avid 和可选的 typeMode
2317
+ * @returns 统一格式的API响应
2318
+ */
2319
+ convertAvToBv: createBoundBilibiliApiMethod("AV\u8F6CBV", cookie),
2320
+ /**
2321
+ * 将 BV 号转换为 AV 号
2322
+ * @param options 请求参数,包含 bvid 和可选的 typeMode
2323
+ * @returns 统一格式的API响应
2324
+ */
2325
+ convertBvToAv: createBoundBilibiliApiMethod("BV\u8F6CAV", cookie)
2326
+ };
2327
+ };
2328
+ var ApiError = class extends Error {
2329
+ code;
2330
+ platform;
2331
+ /**
2332
+ * 构造API错误
2333
+ * @param message - 错误消息
2334
+ * @param code - 错误代码
2335
+ * @param platform - 平台名称
2336
+ */
2337
+ constructor(message, code = 500, platform = "unknown") {
2338
+ super(message);
2339
+ this.name = "ApiError";
2340
+ this.code = code;
2341
+ this.platform = platform;
2342
+ }
2343
+ };
2344
+ var ValidationError = class _ValidationError extends Error {
2345
+ errors;
2346
+ requestPath;
2347
+ /**
2348
+ * 构造参数验证错误
2349
+ * @param message - 错误消息
2350
+ * @param errors - 详细错误信息
2351
+ * @param requestPath - HTTP请求路径
2352
+ */
2353
+ constructor(message, errors, requestPath) {
2354
+ super(message);
2355
+ this.name = "ValidationError";
2356
+ this.errors = errors;
2357
+ this.requestPath = requestPath;
2358
+ }
2359
+ /**
2360
+ * 从Zod错误创建验证错误
2361
+ * @param zodError - Zod验证错误
2362
+ * @param requestPath - HTTP请求路径
2363
+ * @returns 验证错误实例
2364
+ */
2365
+ static fromZodError(zodError, requestPath) {
2366
+ const errors = zodError.errors.map((err) => ({
2367
+ field: err.path.join("."),
2368
+ message: err.message
2369
+ }));
2370
+ return new _ValidationError("\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25", errors, requestPath);
2371
+ }
2372
+ };
2373
+ var handleError = (error, requestPath) => {
2374
+ if (error instanceof ValidationError) {
2352
2375
  return {
2353
- code: "UNKNOWN_ERROR" /* UNKNOWN */,
2376
+ code: 400,
2377
+ message: error.message,
2354
2378
  data: null,
2355
- amagiError: {
2356
- errorDescription: "\u672A\u77E5\u9519\u8BEF",
2357
- requestType: options.methodType,
2358
- requestUrl: options.url
2359
- },
2360
- amagiMessage: warningMessage
2379
+ errors: error.errors,
2380
+ requestPath: error.requestPath || requestPath
2361
2381
  };
2362
2382
  }
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
2383
+ if (error instanceof ApiError) {
2384
+ return {
2385
+ code: error.code,
2386
+ message: error.message,
2387
+ data: null,
2388
+ platform: error.platform,
2389
+ requestPath
2381
2390
  };
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
2391
  }
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}`);
2392
+ if (error instanceof zod.z.ZodError) {
2393
+ const validationError = ValidationError.fromZodError(error, requestPath);
2394
+ return handleError(validationError, requestPath);
2410
2395
  }
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;
2396
+ const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
2397
+ return {
2398
+ code: 500,
2399
+ message: errorMessage,
2400
+ data: null,
2401
+ requestPath
2402
+ };
2403
+ };
2404
+
2405
+ // src/middleware/validation.ts
2406
+ var createValidationMiddleware = (validateFn, methodType) => {
2407
+ return (req, res, next) => {
2408
+ try {
2409
+ const params = { ...req.query, ...req.body };
2410
+ const validatedParams = validateFn(methodType, params);
2411
+ req.validatedParams = validatedParams;
2412
+ next();
2413
+ } catch (error) {
2414
+ const errorResponse = handleError(error, req.originalUrl);
2415
+ res.status(errorResponse.code || 500).json(errorResponse);
2422
2416
  }
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
- }
2417
+ };
2418
+ };
2419
+ var createDouyinValidationMiddleware = (methodType) => createValidationMiddleware(validateDouyinParams, methodType);
2420
+ var createBilibiliValidationMiddleware = (methodType) => createValidationMiddleware(validateBilibiliParams, methodType);
2421
+ var createKuaishouValidationMiddleware = (methodType) => createValidationMiddleware(validateKuaishouParams, methodType);
2435
2422
  var createBilibiliRouteHandler = (dataFetcher, methodType, cookie) => {
2436
2423
  return async (req, res) => {
2437
2424
  try {
@@ -2556,232 +2543,203 @@ var bilibiliUtils = {
2556
2543
  };
2557
2544
 
2558
2545
  // src/platform/douyin/DouyinApi.ts
2546
+ var createDouyinApiMethod = (methodType) => {
2547
+ return async (options, cookie) => {
2548
+ return await getDouyinData(methodType, options, cookie);
2549
+ };
2550
+ };
2551
+ var createBoundDouyinApiMethod = (methodType, cookie) => {
2552
+ return async (options) => {
2553
+ return await getDouyinData(methodType, options, cookie);
2554
+ };
2555
+ };
2559
2556
  var douyin = {
2560
2557
  /**
2561
2558
  * 聚合解析 (视频/图集/合辑)
2562
2559
  * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2563
2560
  * @param cookie 有效的用户 Cookie
2564
- * @returns 统一格式的API响应
2561
+ * @returns 统一格式的API响应,包含视频、图集或合辑数据
2565
2562
  */
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
- },
2563
+ getWorkInfo: createDouyinApiMethod("\u805A\u5408\u89E3\u6790"),
2575
2564
  /**
2576
2565
  * 获取视频作品数据
2577
2566
  * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2578
2567
  * @param cookie 有效的用户 Cookie
2579
- * @returns 统一格式的API响应
2568
+ * @returns 统一格式的API响应,包含视频作品详细信息
2580
2569
  */
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
- },
2570
+ getVideoWorkInfo: createDouyinApiMethod("\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
2590
2571
  /**
2591
2572
  * 获取图集作品数据
2592
2573
  * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2593
2574
  * @param cookie 有效的用户 Cookie
2594
- * @returns 统一格式的API响应
2575
+ * @returns 统一格式的API响应,包含图集作品详细信息
2595
2576
  */
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
- },
2577
+ getImageAlbumWorkInfo: createDouyinApiMethod("\u56FE\u96C6\u4F5C\u54C1\u6570\u636E"),
2605
2578
  /**
2606
2579
  * 获取合辑作品数据
2607
2580
  * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2608
2581
  * @param cookie 有效的用户 Cookie
2609
- * @returns 统一格式的API响应
2582
+ * @returns 统一格式的API响应,包含合辑作品详细信息
2610
2583
  */
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
- },
2584
+ getSlidesWorkInfo: createDouyinApiMethod("\u5408\u8F91\u4F5C\u54C1\u6570\u636E"),
2620
2585
  /**
2621
2586
  * 获取评论数据
2622
2587
  * @param options 请求参数,包含 aweme_id, 可选的 number, cursor 和 typeMode
2623
2588
  * @param cookie 有效的用户 Cookie
2624
- * @returns 统一格式的API响应
2589
+ * @returns 统一格式的API响应,包含评论列表数据
2625
2590
  */
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
- },
2591
+ getComments: createDouyinApiMethod("\u8BC4\u8BBA\u6570\u636E"),
2635
2592
  /**
2636
2593
  * 获取指定评论回复数据
2637
2594
  * @param options 请求参数,包含 aweme_id, comment_id, 可选的 number, cursor 和 typeMode
2638
2595
  * @param cookie 有效的用户 Cookie
2639
- * @returns 统一格式的API响应
2596
+ * @returns 统一格式的API响应,包含评论回复数据
2640
2597
  */
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
- },
2598
+ getCommentReplies: createDouyinApiMethod("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E"),
2650
2599
  /**
2651
2600
  * 获取用户主页数据
2652
2601
  * @param options 请求参数,包含 sec_uid 和可选的 typeMode
2653
2602
  * @param cookie 有效的用户 Cookie
2654
- * @returns 统一格式的API响应
2603
+ * @returns 统一格式的API响应,包含用户详细信息
2655
2604
  */
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
- },
2605
+ getUserProfile: createDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E"),
2665
2606
  /**
2666
2607
  * 获取 Emoji 数据
2667
2608
  * @param options 可选的请求参数 (主要用于 typeMode)
2668
2609
  * @param cookie 可选的用户 Cookie
2669
- * @returns 统一格式的API响应
2610
+ * @returns 统一格式的API响应,包含Emoji列表数据
2670
2611
  */
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
- },
2612
+ getEmojiList: createDouyinApiMethod("Emoji\u6570\u636E"),
2680
2613
  /**
2681
2614
  * 获取动态表情数据
2682
2615
  * @param options 可选的请求参数 (主要用于 typeMode)
2683
2616
  * @param cookie 有效的用户 Cookie
2684
- * @returns 统一格式的API响应
2617
+ * @returns 统一格式的API响应,包含动态表情数据
2685
2618
  */
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
- },
2619
+ getEmojiProList: createDouyinApiMethod("\u52A8\u6001\u8868\u60C5\u6570\u636E"),
2695
2620
  /**
2696
2621
  * 获取用户主页视频列表数据
2697
2622
  * @param options 请求参数,包含 sec_uid, 可选的 number, max_cursor 和 typeMode
2698
2623
  * @param cookie 有效的用户 Cookie
2699
- * @returns 统一格式的API响应
2624
+ * @returns 统一格式的API响应,包含用户发布的视频列表
2700
2625
  */
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
- },
2626
+ getUserVideos: createDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E"),
2710
2627
  /**
2711
2628
  * 获取音乐数据
2712
2629
  * @param options 请求参数,包含 music_id 和可选的 typeMode
2713
2630
  * @param cookie 有效的用户 Cookie
2714
- * @returns 统一格式的API响应
2631
+ * @returns 统一格式的API响应,包含音乐详细信息
2715
2632
  */
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
- },
2633
+ getMusicInfo: createDouyinApiMethod("\u97F3\u4E50\u6570\u636E"),
2725
2634
  /**
2726
2635
  * 获取热点词数据
2727
2636
  * @param options 请求参数,包含 query, 可选的 number 和 typeMode
2728
2637
  * @param cookie 有效的用户 Cookie
2729
- * @returns 统一格式的API响应
2638
+ * @returns 统一格式的API响应,包含热点搜索词列表
2730
2639
  */
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
- },
2640
+ getSuggestWords: createDouyinApiMethod("\u70ED\u70B9\u8BCD\u6570\u636E"),
2740
2641
  /**
2741
2642
  * 获取搜索数据
2742
2643
  * @param options 请求参数,包含 query, 可选的 number, search_id, cursor 和 typeMode
2743
2644
  * @param cookie 有效的用户 Cookie
2744
- * @returns 统一格式的API响应
2645
+ * @returns 统一格式的API响应,包含搜索结果数据
2745
2646
  */
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
- },
2647
+ search: createDouyinApiMethod("\u641C\u7D22\u6570\u636E"),
2755
2648
  /**
2756
2649
  * 获取直播间信息
2757
2650
  * @param options 请求参数,包含 sec_uid 和可选的 typeMode
2758
2651
  * @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响应
2652
+ * @returns 统一格式的API响应,包含直播间详细信息
2775
2653
  */
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
- }
2654
+ getLiveRoomInfo: createDouyinApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E")
2655
+ };
2656
+ var createBoundDouyinApi = (cookie) => {
2657
+ return {
2658
+ /**
2659
+ * 聚合解析 (视频/图集/合辑)
2660
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2661
+ * @returns 统一格式的API响应,包含视频、图集或合辑数据
2662
+ */
2663
+ getWorkInfo: createBoundDouyinApiMethod("\u805A\u5408\u89E3\u6790", cookie),
2664
+ /**
2665
+ * 获取视频作品数据
2666
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2667
+ * @returns 统一格式的API响应,包含视频作品详细信息
2668
+ */
2669
+ getVideoWorkInfo: createBoundDouyinApiMethod("\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie),
2670
+ /**
2671
+ * 获取图集作品数据
2672
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2673
+ * @returns 统一格式的API响应,包含图集作品详细信息
2674
+ */
2675
+ getImageAlbumWorkInfo: createBoundDouyinApiMethod("\u56FE\u96C6\u4F5C\u54C1\u6570\u636E", cookie),
2676
+ /**
2677
+ * 获取合辑作品数据
2678
+ * @param options 请求参数,包含 aweme_id 和可选的 typeMode
2679
+ * @returns 统一格式的API响应,包含合辑作品详细信息
2680
+ */
2681
+ getSlidesWorkInfo: createBoundDouyinApiMethod("\u5408\u8F91\u4F5C\u54C1\u6570\u636E", cookie),
2682
+ /**
2683
+ * 获取评论数据
2684
+ * @param options 请求参数,包含 aweme_id, 可选的 number, cursor 和 typeMode
2685
+ * @returns 统一格式的API响应,包含评论列表数据
2686
+ */
2687
+ getComments: createBoundDouyinApiMethod("\u8BC4\u8BBA\u6570\u636E", cookie),
2688
+ /**
2689
+ * 获取指定评论回复数据
2690
+ * @param options 请求参数,包含 aweme_id, comment_id, 可选的 number, cursor 和 typeMode
2691
+ * @returns 统一格式的API响应,包含评论回复数据
2692
+ */
2693
+ getCommentReplies: createBoundDouyinApiMethod("\u6307\u5B9A\u8BC4\u8BBA\u56DE\u590D\u6570\u636E", cookie),
2694
+ /**
2695
+ * 获取用户主页数据
2696
+ * @param options 请求参数,包含 sec_uid 和可选的 typeMode
2697
+ * @returns 统一格式的API响应,包含用户详细信息
2698
+ */
2699
+ getUserProfile: createBoundDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u6570\u636E", cookie),
2700
+ /**
2701
+ * 获取 Emoji 数据
2702
+ * @param options 可选的请求参数 (主要用于 typeMode)
2703
+ * @returns 统一格式的API响应,包含Emoji列表数据
2704
+ */
2705
+ getEmojiList: createBoundDouyinApiMethod("Emoji\u6570\u636E", cookie),
2706
+ /**
2707
+ * 获取动态表情数据
2708
+ * @param options 可选的请求参数 (主要用于 typeMode)
2709
+ * @returns 统一格式的API响应,包含动态表情数据
2710
+ */
2711
+ getEmojiProList: createBoundDouyinApiMethod("\u52A8\u6001\u8868\u60C5\u6570\u636E", cookie),
2712
+ /**
2713
+ * 获取用户主页视频列表数据
2714
+ * @param options 请求参数,包含 sec_uid, 可选的 number, max_cursor 和 typeMode
2715
+ * @returns 统一格式的API响应,包含用户发布的视频列表
2716
+ */
2717
+ getUserVideos: createBoundDouyinApiMethod("\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E", cookie),
2718
+ /**
2719
+ * 获取音乐数据
2720
+ * @param options 请求参数,包含 music_id 和可选的 typeMode
2721
+ * @returns 统一格式的API响应,包含音乐详细信息
2722
+ */
2723
+ getMusicInfo: createBoundDouyinApiMethod("\u97F3\u4E50\u6570\u636E", cookie),
2724
+ /**
2725
+ * 获取热点词数据
2726
+ * @param options 请求参数,包含 query, 可选的 number 和 typeMode
2727
+ * @returns 统一格式的API响应,包含热点搜索词列表
2728
+ */
2729
+ getSuggestWords: createBoundDouyinApiMethod("\u70ED\u70B9\u8BCD\u6570\u636E", cookie),
2730
+ /**
2731
+ * 获取搜索数据
2732
+ * @param options 请求参数,包含 query, 可选的 number, search_id, cursor 和 typeMode
2733
+ * @returns 统一格式的API响应,包含搜索结果数据
2734
+ */
2735
+ search: createBoundDouyinApiMethod("\u641C\u7D22\u6570\u636E", cookie),
2736
+ /**
2737
+ * 获取直播间信息
2738
+ * @param options 请求参数,包含 sec_uid 和可选的 typeMode
2739
+ * @returns 统一格式的API响应,包含直播间详细信息
2740
+ */
2741
+ getLiveRoomInfo: createBoundDouyinApiMethod("\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E", cookie)
2742
+ };
2785
2743
  };
2786
2744
  var createDouyinRouteHandler = (dataFetcher, methodType, cookie) => {
2787
2745
  return async (req, res) => {
@@ -2919,6 +2877,16 @@ var createKuaishouRoutes = (cookie) => {
2919
2877
  };
2920
2878
 
2921
2879
  // src/platform/kuaishou/KuaishouApi.ts
2880
+ var createKuaishouApiMethod = (methodType) => {
2881
+ return async (options, cookie) => {
2882
+ return await getKuaishouData(methodType, options, cookie);
2883
+ };
2884
+ };
2885
+ var createBoundKuaishouApiMethod = (methodType, cookie) => {
2886
+ return async (options) => {
2887
+ return await getKuaishouData(methodType, options, cookie);
2888
+ };
2889
+ };
2922
2890
  var kuaishou = {
2923
2891
  /**
2924
2892
  * 获取单个视频作品数据
@@ -2926,42 +2894,43 @@ var kuaishou = {
2926
2894
  * @param cookie 可选的用户 Cookie
2927
2895
  * @returns 统一格式的API响应
2928
2896
  */
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
- },
2897
+ getWorkInfo: createKuaishouApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E"),
2937
2898
  /**
2938
2899
  * 获取评论数据
2939
2900
  * @param options 请求参数,包含 photoId 和可选的 typeMode
2940
2901
  * @param cookie 可选的用户 Cookie
2941
2902
  * @returns 统一格式的API响应
2942
2903
  */
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
- },
2904
+ getComments: createKuaishouApiMethod("\u8BC4\u8BBA\u6570\u636E"),
2951
2905
  /**
2952
2906
  * 获取 Emoji 数据
2953
2907
  * @param options 可选的请求参数 (主要用于 typeMode)
2954
2908
  * @param cookie 可选的用户 Cookie
2955
2909
  * @returns 统一格式的API响应
2956
2910
  */
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
- }
2911
+ getEmojiList: createKuaishouApiMethod("Emoji\u6570\u636E")
2912
+ };
2913
+ var createBoundKuaishouApi = (cookie) => {
2914
+ return {
2915
+ /**
2916
+ * 获取单个视频作品数据
2917
+ * @param options 请求参数,包含 photoId 和可选的 typeMode
2918
+ * @returns 统一格式的API响应
2919
+ */
2920
+ getWorkInfo: createBoundKuaishouApiMethod("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E", cookie),
2921
+ /**
2922
+ * 获取评论数据
2923
+ * @param options 请求参数,包含 photoId 和可选的 typeMode
2924
+ * @returns 统一格式的API响应
2925
+ */
2926
+ getComments: createBoundKuaishouApiMethod("\u8BC4\u8BBA\u6570\u636E", cookie),
2927
+ /**
2928
+ * 获取 Emoji 数据
2929
+ * @param options 可选的请求参数 (主要用于 typeMode)
2930
+ * @returns 统一格式的API响应
2931
+ */
2932
+ getEmojiList: createBoundKuaishouApiMethod("Emoji\u6570\u636E", cookie)
2933
+ };
2965
2934
  };
2966
2935
 
2967
2936
  // src/platform/kuaishou/index.ts
@@ -3015,15 +2984,15 @@ var fetchBilibiliData = getBilibiliData2;
3015
2984
  var fetchKuaishouData = getKuaishouData2;
3016
2985
  var v4CompatibilityMiddleware = (req, res, next) => {
3017
2986
  const originalJson = res.json;
3018
- res.json = function(data2) {
2987
+ res.json = (data2) => {
3019
2988
  if (data2 && typeof data2 === "object" && "data" in data2 && "message" in data2 && "code" in data2) {
3020
2989
  const v4Response = {
3021
2990
  ...data2.data,
3022
2991
  ...data2.requestPath && { requestPath: data2.requestPath }
3023
2992
  };
3024
- return originalJson.call(this, v4Response);
2993
+ return originalJson.call(void 0, v4Response);
3025
2994
  }
3026
- return originalJson.call(this, data2);
2995
+ return originalJson.call(void 0, data2);
3027
2996
  };
3028
2997
  next();
3029
2998
  };
@@ -3127,29 +3096,29 @@ var CreateApp = createAmagiClient;
3127
3096
  var Client = CreateApp;
3128
3097
  var amagi = Client;
3129
3098
  /*!
3130
- * @ikenxuan/amagi v4 (default)
3099
+ * @ikenxuan/amagi
3131
3100
  * Copyright(c) 2023 ikenxuan
3132
3101
  * GPL-3.0 Licensed
3133
3102
  */
3134
3103
 
3135
3104
  exports.CreateApp = CreateApp;
3136
- exports.KuaishouAPI = KuaishouAPI;
3137
3105
  exports.Networks = Networks;
3138
3106
  exports.amagi = amagi;
3139
3107
  exports.amagiClient = amagiClient;
3140
3108
  exports.av2bv = av2bv;
3141
3109
  exports.bilibili = bilibili;
3142
- exports.bilibiliAPI = bilibiliAPI;
3143
3110
  exports.bilibiliApiUrls = bilibiliApiUrls;
3144
3111
  exports.bilibiliErrorCodeMap = bilibiliErrorCodeMap;
3145
3112
  exports.bilibiliUtils = bilibiliUtils;
3146
3113
  exports.bv2av = bv2av;
3147
3114
  exports.createBilibiliRoutes = createBilibiliRoutes;
3115
+ exports.createBoundBilibiliApi = createBoundBilibiliApi;
3116
+ exports.createBoundDouyinApi = createBoundDouyinApi;
3117
+ exports.createBoundKuaishouApi = createBoundKuaishouApi;
3148
3118
  exports.createDouyinRoutes = createDouyinRoutes;
3149
3119
  exports.createKuaishouRoutes = createKuaishouRoutes;
3150
3120
  exports.default = Client;
3151
3121
  exports.douyin = douyin;
3152
- exports.douyinAPI = douyinAPI;
3153
3122
  exports.douyinApiUrls = douyinApiUrls;
3154
3123
  exports.douyinSign = douyinSign;
3155
3124
  exports.douyinUtils = douyinUtils;
@@ -3161,7 +3130,6 @@ exports.getDouyinData = getDouyinData2;
3161
3130
  exports.getKuaishouData = getKuaishouData2;
3162
3131
  exports.httpLogger = httpLogger;
3163
3132
  exports.kuaishou = kuaishou;
3164
- exports.kuaishouAPI = kuaishouAPI;
3165
3133
  exports.kuaishouApiUrls = kuaishouApiUrls;
3166
3134
  exports.kuaishouUtils = kuaishouUtils;
3167
3135
  exports.logMiddleware = logMiddleware;