@ikenxuan/amagi 6.1.2 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/default/index.cjs +1073 -971
- package/dist/default/index.d.ts +17601 -16590
- package/dist/default/index.mjs +1063 -963
- package/dist/exports/axios.cjs +9 -8
- package/dist/exports/axios.mjs +2 -4
- package/dist/exports/chalk.cjs +7 -7
- package/dist/exports/chalk.mjs +2 -3
- package/dist/exports/express.cjs +3 -4
- package/dist/exports/express.mjs +1 -2
- package/dist/{chunk-CbDLau6x.cjs → rolldown-runtime-D6vf50IK.cjs} +13 -19
- package/package.json +21 -21
package/dist/default/index.cjs
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
const require_rolldown_runtime = require("../rolldown-runtime-D6vf50IK.cjs");
|
|
3
6
|
let node_url = require("node:url");
|
|
4
|
-
node_url =
|
|
7
|
+
node_url = require_rolldown_runtime.__toESM(node_url, 1);
|
|
5
8
|
let node_events = require("node:events");
|
|
6
9
|
let zod = require("zod");
|
|
7
|
-
zod =
|
|
10
|
+
zod = require_rolldown_runtime.__toESM(zod, 1);
|
|
8
11
|
let _ikenxuan_xhshow_ts = require("@ikenxuan/xhshow-ts");
|
|
9
12
|
let node_crypto = require("node:crypto");
|
|
10
|
-
node_crypto =
|
|
13
|
+
node_crypto = require_rolldown_runtime.__toESM(node_crypto, 1);
|
|
11
14
|
let axios = require("axios");
|
|
12
|
-
axios =
|
|
15
|
+
axios = require_rolldown_runtime.__toESM(axios, 1);
|
|
13
16
|
let chalk = require("chalk");
|
|
14
17
|
let protobufjs = require("protobufjs");
|
|
15
|
-
protobufjs =
|
|
18
|
+
protobufjs = require_rolldown_runtime.__toESM(protobufjs, 1);
|
|
16
19
|
let express = require("express");
|
|
17
|
-
express =
|
|
18
|
-
|
|
20
|
+
express = require_rolldown_runtime.__toESM(express, 1);
|
|
19
21
|
//#region src/utils/deprecation.ts
|
|
20
22
|
/**
|
|
21
23
|
* 废弃 API 注册表
|
|
@@ -74,7 +76,9 @@ function checkDeprecation(apiName) {
|
|
|
74
76
|
* @returns 格式化的废弃提示消息字符串
|
|
75
77
|
*/
|
|
76
78
|
function buildDeprecationMessage(config) {
|
|
77
|
-
const lines = [`[DEPRECATED] "${config.name}" 已在 v${config.deprecatedIn}
|
|
79
|
+
const lines = [`[DEPRECATED] "${config.name}" 已在 v${config.deprecatedIn} 版本废弃。`];
|
|
80
|
+
if (config.replacement) lines.push(`请使用 "${config.replacement}" 替代。`);
|
|
81
|
+
else lines.push("此接口已被上游删除,无法继续使用,无可用替代方案。");
|
|
78
82
|
if (config.removedIn) lines.push(`此 API 将在 v${config.removedIn} 版本移除。`);
|
|
79
83
|
if (config.migrationGuide) lines.push(`迁移指南: ${config.migrationGuide}`);
|
|
80
84
|
return lines.join("\n");
|
|
@@ -182,10 +186,6 @@ registerDeprecatedApi({
|
|
|
182
186
|
name: "动态详情数据",
|
|
183
187
|
replacement: "fetchDynamicDetail"
|
|
184
188
|
},
|
|
185
|
-
{
|
|
186
|
-
name: "动态卡片数据",
|
|
187
|
-
replacement: "fetchDynamicCard"
|
|
188
|
-
},
|
|
189
189
|
{
|
|
190
190
|
name: "直播间信息",
|
|
191
191
|
replacement: "fetchLiveRoomInfo"
|
|
@@ -335,7 +335,20 @@ registerDeprecatedApi({
|
|
|
335
335
|
throwError: true
|
|
336
336
|
});
|
|
337
337
|
});
|
|
338
|
-
|
|
338
|
+
registerDeprecatedApi({
|
|
339
|
+
name: `methodType: '动态卡片数据'`,
|
|
340
|
+
deprecatedIn: "6.0.0",
|
|
341
|
+
removedIn: "7.0.0",
|
|
342
|
+
migrationGuide: "https://amagi-docs.vercel.app/docs/changelog/6.1.3",
|
|
343
|
+
throwError: false
|
|
344
|
+
});
|
|
345
|
+
registerDeprecatedApi({
|
|
346
|
+
name: "fetchDynamicCard",
|
|
347
|
+
deprecatedIn: "6.1.3",
|
|
348
|
+
removedIn: "7.0.0",
|
|
349
|
+
migrationGuide: "https://amagi-docs.vercel.app/docs/changelog/6.1.3",
|
|
350
|
+
throwError: false
|
|
351
|
+
});
|
|
339
352
|
//#endregion
|
|
340
353
|
//#region src/model/DataFetchers.ts
|
|
341
354
|
/**
|
|
@@ -443,7 +456,6 @@ function getXiaohongshuData(..._args) {
|
|
|
443
456
|
checkDeprecation("getXiaohongshuData");
|
|
444
457
|
throw new Error("getXiaohongshuData 已废弃");
|
|
445
458
|
}
|
|
446
|
-
|
|
447
459
|
//#endregion
|
|
448
460
|
//#region src/platform/bilibili/API.ts
|
|
449
461
|
/**
|
|
@@ -457,133 +469,138 @@ var BilibiliAPI = class {
|
|
|
457
469
|
return "https://api.bilibili.com/x/web-interface/nav";
|
|
458
470
|
}
|
|
459
471
|
/** 获取视频详细信息 */
|
|
460
|
-
getVideoInfo(data
|
|
461
|
-
return `https://api.bilibili.com/x/web-interface/view?bvid=${data
|
|
472
|
+
getVideoInfo(data) {
|
|
473
|
+
return `https://api.bilibili.com/x/web-interface/view?bvid=${data.bvid}`;
|
|
462
474
|
}
|
|
463
475
|
/** 获取视频流信息 */
|
|
464
|
-
getVideoStream(data
|
|
465
|
-
return `https://api.bilibili.com/x/player/playurl?avid=${data
|
|
476
|
+
getVideoStream(data) {
|
|
477
|
+
return `https://api.bilibili.com/x/player/playurl?avid=${data.avid}&cid=${data.cid}`;
|
|
466
478
|
}
|
|
467
479
|
/**
|
|
468
480
|
* 获取评论区明细
|
|
469
481
|
* @see https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/readme.md#评论区类型代码
|
|
470
482
|
*/
|
|
471
|
-
getComments(data
|
|
483
|
+
getComments(data) {
|
|
472
484
|
const params = new URLSearchParams({
|
|
473
|
-
oid: data
|
|
474
|
-
type: data
|
|
475
|
-
mode: (data
|
|
485
|
+
oid: data.oid.toString(),
|
|
486
|
+
type: data.type.toString(),
|
|
487
|
+
mode: (data.mode ?? 3).toString(),
|
|
476
488
|
plat: "1",
|
|
477
489
|
seek_rpid: "",
|
|
478
490
|
web_location: "1315875"
|
|
479
491
|
});
|
|
480
|
-
if (data
|
|
492
|
+
if (data.pagination_str) params.append("pagination_str", JSON.stringify({ offset: data.pagination_str }));
|
|
481
493
|
else params.append("pagination_str", JSON.stringify({ offset: "" }));
|
|
482
494
|
return `https://api.bilibili.com/x/v2/reply/wbi/main?${params.toString()}`;
|
|
483
495
|
}
|
|
484
496
|
/** 获取评论区状态 */
|
|
485
|
-
getCommentStatus(data
|
|
486
|
-
return `https://api.bilibili.com/x/v2/reply/subject/description?type=${data
|
|
497
|
+
getCommentStatus(data) {
|
|
498
|
+
return `https://api.bilibili.com/x/v2/reply/subject/description?type=${data.type}&oid=${data.oid}`;
|
|
487
499
|
}
|
|
488
500
|
/** 获取指定评论的回复 */
|
|
489
|
-
getCommentReplies(data
|
|
490
|
-
return `https://api.bilibili.com/x/v2/reply/reply?type=${data
|
|
501
|
+
getCommentReplies(data) {
|
|
502
|
+
return `https://api.bilibili.com/x/v2/reply/reply?type=${data.type}&oid=${data.oid}&root=${data.root}&ps=${data.number}`;
|
|
491
503
|
}
|
|
492
504
|
/** 获取表情列表 */
|
|
493
505
|
getEmojiList() {
|
|
494
506
|
return "https://api.bilibili.com/x/emote/user/panel/web?business=reply&web_location=0.0";
|
|
495
507
|
}
|
|
496
508
|
/** 获取番剧明细 */
|
|
497
|
-
getBangumiInfo(data
|
|
498
|
-
if (data
|
|
499
|
-
else if (data
|
|
509
|
+
getBangumiInfo(data) {
|
|
510
|
+
if (data.ep_id) return `https://api.bilibili.com/pgc/view/web/season?ep_id=${data.ep_id}`;
|
|
511
|
+
else if (data.season_id) return `https://api.bilibili.com/pgc/view/web/season?season_id=${data.season_id}`;
|
|
500
512
|
else throw new Error("Missing required parameter: ep_id or season_id");
|
|
501
513
|
}
|
|
502
514
|
/** 获取番剧视频流信息 */
|
|
503
|
-
getBangumiStream(data
|
|
504
|
-
return `https://api.bilibili.com/pgc/player/web/playurl?cid=${data
|
|
515
|
+
getBangumiStream(data) {
|
|
516
|
+
return `https://api.bilibili.com/pgc/player/web/playurl?cid=${data.cid}&ep_id=${data.ep_id}`;
|
|
505
517
|
}
|
|
506
518
|
/** 获取用户空间动态 */
|
|
507
|
-
getUserDynamicList(data
|
|
519
|
+
getUserDynamicList(data) {
|
|
508
520
|
return `https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?${new URLSearchParams({
|
|
509
|
-
host_mid: data
|
|
521
|
+
host_mid: data.host_mid.toString(),
|
|
510
522
|
offset: "",
|
|
511
523
|
platform: "web",
|
|
512
524
|
features: "itemOpusStyle,listOnlyfans,opusBigCover,onlyfansVote,forwardListHidden,decorationCard,commentsNewVersion,onlyfansAssetsV2,ugcDelete,onlyfansQaCard,avatarAutoTheme,sunflowerStyle,eva3CardOpus,eva3CardVideo,eva3CardComment"
|
|
513
525
|
}).toString()}`;
|
|
514
526
|
}
|
|
515
527
|
/** 获取动态详情 */
|
|
516
|
-
getDynamicDetail(data
|
|
517
|
-
return `https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?id=${data
|
|
528
|
+
getDynamicDetail(data) {
|
|
529
|
+
return `https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?id=${data.dynamic_id}&features=itemOpusStyle,opusBigCover,onlyfansVote,endFooterHidden,decorationCard,onlyfansAssetsV2,ugcDelete,onlyfansQaCard,editable,opusPrivateVisible,avatarAutoTheme`;
|
|
518
530
|
}
|
|
519
|
-
/**
|
|
520
|
-
|
|
521
|
-
|
|
531
|
+
/**
|
|
532
|
+
* 获取动态卡片信息
|
|
533
|
+
*
|
|
534
|
+
* @deprecated B站官方已于 `2025-08-09` 删除原 `dynamic_svr` 接口,该接口已停用。
|
|
535
|
+
* 调用将返回错误信息,请使用 {@link getDynamicDetail} 替代。
|
|
536
|
+
*/
|
|
537
|
+
getDynamicCard(data) {
|
|
538
|
+
return this.getDynamicDetail(data);
|
|
522
539
|
}
|
|
523
540
|
/** 获取用户名片信息 */
|
|
524
|
-
getUserCard(data
|
|
525
|
-
return `https://api.bilibili.com/x/web-interface/card?mid=${data
|
|
541
|
+
getUserCard(data) {
|
|
542
|
+
return `https://api.bilibili.com/x/web-interface/card?mid=${data.host_mid}&photo=true`;
|
|
526
543
|
}
|
|
527
544
|
/** 获取直播间信息 */
|
|
528
|
-
getLiveRoomInfo(data
|
|
529
|
-
return `https://api.live.bilibili.com/room/v1/Room/get_info?room_id=${data
|
|
545
|
+
getLiveRoomInfo(data) {
|
|
546
|
+
return `https://api.live.bilibili.com/room/v1/Room/get_info?room_id=${data.room_id}`;
|
|
530
547
|
}
|
|
531
548
|
/** 获取直播间初始化信息 */
|
|
532
|
-
getLiveRoomInit(data
|
|
533
|
-
return `https://api.live.bilibili.com/room/v1/Room/room_init?id=${data
|
|
549
|
+
getLiveRoomInit(data) {
|
|
550
|
+
return `https://api.live.bilibili.com/room/v1/Room/room_init?id=${data.room_id}`;
|
|
534
551
|
}
|
|
535
552
|
/** 申请登录二维码 */
|
|
536
553
|
getLoginQrcode() {
|
|
537
554
|
return "https://passport.bilibili.com/x/passport-login/web/qrcode/generate";
|
|
538
555
|
}
|
|
539
556
|
/** 查询二维码状态 */
|
|
540
|
-
getQrcodeStatus(data
|
|
541
|
-
return `https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=${data
|
|
557
|
+
getQrcodeStatus(data) {
|
|
558
|
+
return `https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=${data.qrcode_key}`;
|
|
542
559
|
}
|
|
543
560
|
/** 获取UP主总播放量 */
|
|
544
|
-
getUploaderTotalViews(data
|
|
545
|
-
return `https://api.bilibili.com/x/space/upstat?mid=${data
|
|
561
|
+
getUploaderTotalViews(data) {
|
|
562
|
+
return `https://api.bilibili.com/x/space/upstat?mid=${data.host_mid}`;
|
|
546
563
|
}
|
|
547
564
|
/** 获取专栏正文内容 */
|
|
548
|
-
getArticleContent(data
|
|
549
|
-
return `https://api.bilibili.com/x/article/view?id=${data
|
|
565
|
+
getArticleContent(data) {
|
|
566
|
+
return `https://api.bilibili.com/x/article/view?id=${data.id}`;
|
|
550
567
|
}
|
|
551
568
|
/** 获取专栏显示卡片信息 */
|
|
552
|
-
getArticleCards(data
|
|
553
|
-
return `https://api.bilibili.com/x/article/cards?ids=${Array.isArray(data
|
|
569
|
+
getArticleCards(data) {
|
|
570
|
+
return `https://api.bilibili.com/x/article/cards?ids=${Array.isArray(data.ids) ? data.ids.join(",") : data.ids}`;
|
|
554
571
|
}
|
|
555
572
|
/** 获取专栏文章基本信息 */
|
|
556
|
-
getArticleInfo(data
|
|
557
|
-
return `https://api.bilibili.com/x/article/viewinfo?id=${data
|
|
573
|
+
getArticleInfo(data) {
|
|
574
|
+
return `https://api.bilibili.com/x/article/viewinfo?id=${data.id}`;
|
|
558
575
|
}
|
|
559
576
|
/** 获取文集基本信息 */
|
|
560
|
-
getArticleListInfo(data
|
|
561
|
-
return `https://api.bilibili.com/x/article/list/web/articles?id=${data
|
|
577
|
+
getArticleListInfo(data) {
|
|
578
|
+
return `https://api.bilibili.com/x/article/list/web/articles?id=${data.id}`;
|
|
562
579
|
}
|
|
563
580
|
/** 获取用户空间详细信息 */
|
|
564
|
-
getUserSpaceInfo(data
|
|
565
|
-
return `https://api.bilibili.com/x/space/wbi/acc/info?mid=${data
|
|
581
|
+
getUserSpaceInfo(data) {
|
|
582
|
+
return `https://api.bilibili.com/x/space/wbi/acc/info?mid=${data.host_mid}`;
|
|
566
583
|
}
|
|
567
584
|
/** 从 v_voucher 申请验证码 */
|
|
568
|
-
getCaptchaFromVoucher(data
|
|
585
|
+
getCaptchaFromVoucher(data) {
|
|
569
586
|
return {
|
|
570
587
|
Url: "https://api.bilibili.com/x/gaia-vgate/v1/register",
|
|
571
588
|
Body: {
|
|
572
|
-
...data
|
|
573
|
-
v_voucher: data
|
|
589
|
+
...data.csrf !== void 0 && { csrf: data.csrf },
|
|
590
|
+
v_voucher: data.v_voucher
|
|
574
591
|
}
|
|
575
592
|
};
|
|
576
593
|
}
|
|
577
594
|
/** 验证验证码结果 */
|
|
578
|
-
validateCaptcha(data
|
|
595
|
+
validateCaptcha(data) {
|
|
579
596
|
return {
|
|
580
597
|
Url: "https://api.bilibili.com/x/gaia-vgate/v1/validate",
|
|
581
598
|
Body: {
|
|
582
|
-
challenge: data
|
|
583
|
-
token: data
|
|
584
|
-
validate: data
|
|
585
|
-
seccode: data
|
|
586
|
-
...data
|
|
599
|
+
challenge: data.challenge,
|
|
600
|
+
token: data.token,
|
|
601
|
+
validate: data.validate,
|
|
602
|
+
seccode: data.seccode,
|
|
603
|
+
...data.csrf !== void 0 && { csrf: data.csrf }
|
|
587
604
|
}
|
|
588
605
|
};
|
|
589
606
|
}
|
|
@@ -591,17 +608,16 @@ var BilibiliAPI = class {
|
|
|
591
608
|
* 获取实时弹幕(web端 protobuf 接口)
|
|
592
609
|
* @see https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/danmaku/danmaku_proto.md
|
|
593
610
|
*/
|
|
594
|
-
getVideoDanmaku(data
|
|
611
|
+
getVideoDanmaku(data) {
|
|
595
612
|
return `https://api.bilibili.com/x/v2/dm/web/seg.so?${new URLSearchParams({
|
|
596
613
|
type: "1",
|
|
597
|
-
oid: data
|
|
598
|
-
segment_index: (data
|
|
614
|
+
oid: data.cid.toString(),
|
|
615
|
+
segment_index: (data.segment_index ?? 1).toString()
|
|
599
616
|
}).toString()}`;
|
|
600
617
|
}
|
|
601
618
|
};
|
|
602
619
|
/** B站 API URL 构建器实例 */
|
|
603
620
|
const bilibiliApiUrls = new BilibiliAPI();
|
|
604
|
-
|
|
605
621
|
//#endregion
|
|
606
622
|
//#region src/platform/bilibili/BilibiliApi.ts
|
|
607
623
|
/**
|
|
@@ -619,32 +635,59 @@ const createDeprecatedStub$3 = (methodName) => {
|
|
|
619
635
|
* @deprecated v6 已废弃,请使用 bilibiliFetcher 或 client.bilibili.fetcher 替代
|
|
620
636
|
*/
|
|
621
637
|
const bilibili = {
|
|
638
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchVideoInfo 替代 */
|
|
622
639
|
getVideoInfo: createDeprecatedStub$3("getVideoInfo"),
|
|
640
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchVideoStreamUrl 替代 */
|
|
623
641
|
getVideoStream: createDeprecatedStub$3("getVideoStream"),
|
|
642
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchComments 替代 */
|
|
624
643
|
getComments: createDeprecatedStub$3("getComments"),
|
|
644
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchCommentReplies 替代 */
|
|
625
645
|
getCommentReply: createDeprecatedStub$3("getCommentReply"),
|
|
646
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchUserCard 替代 */
|
|
626
647
|
getUserProfile: createDeprecatedStub$3("getUserProfile"),
|
|
648
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchUserDynamicList 替代 */
|
|
627
649
|
getUserDynamic: createDeprecatedStub$3("getUserDynamic"),
|
|
650
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchEmojiList 替代 */
|
|
628
651
|
getEmojiList: createDeprecatedStub$3("getEmojiList"),
|
|
652
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchBangumiInfo 替代 */
|
|
629
653
|
getBangumiInfo: createDeprecatedStub$3("getBangumiInfo"),
|
|
654
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchBangumiStreamUrl 替代 */
|
|
630
655
|
getBangumiStream: createDeprecatedStub$3("getBangumiStream"),
|
|
656
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchDynamicDetail 替代 */
|
|
631
657
|
getDynamicInfo: createDeprecatedStub$3("getDynamicInfo"),
|
|
658
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchDynamicCard 替代 */
|
|
632
659
|
getDynamicCard: createDeprecatedStub$3("getDynamicCard"),
|
|
660
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchLiveRoomInfo 替代 */
|
|
633
661
|
getLiveRoomDetail: createDeprecatedStub$3("getLiveRoomDetail"),
|
|
662
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchLiveRoomInitInfo 替代 */
|
|
634
663
|
getLiveRoomInitInfo: createDeprecatedStub$3("getLiveRoomInitInfo"),
|
|
664
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchLoginStatus 替代 */
|
|
635
665
|
getLoginBasicInfo: createDeprecatedStub$3("getLoginBasicInfo"),
|
|
666
|
+
/** @deprecated 请使用 bilibiliFetcher.requestLoginQrcode 替代 */
|
|
636
667
|
getLoginQrcode: createDeprecatedStub$3("getLoginQrcode"),
|
|
668
|
+
/** @deprecated 请使用 bilibiliFetcher.checkQrcodeStatus 替代 */
|
|
637
669
|
checkQrcodeStatus: createDeprecatedStub$3("checkQrcodeStatus"),
|
|
670
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchUploaderTotalViews 替代 */
|
|
638
671
|
getUserTotalPlayCount: createDeprecatedStub$3("getUserTotalPlayCount"),
|
|
672
|
+
/** @deprecated 请使用 bilibiliFetcher.convertAvToBv 替代 */
|
|
639
673
|
convertAvToBv: createDeprecatedStub$3("convertAvToBv"),
|
|
674
|
+
/** @deprecated 请使用 bilibiliFetcher.convertBvToAv 替代 */
|
|
640
675
|
convertBvToAv: createDeprecatedStub$3("convertBvToAv"),
|
|
676
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchArticleContent 替代 */
|
|
641
677
|
getArticleContent: createDeprecatedStub$3("getArticleContent"),
|
|
678
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchArticleCards 替代 */
|
|
642
679
|
getArticleCard: createDeprecatedStub$3("getArticleCard"),
|
|
680
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchArticleInfo 替代 */
|
|
643
681
|
getArticleInfo: createDeprecatedStub$3("getArticleInfo"),
|
|
682
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchArticleListInfo 替代 */
|
|
644
683
|
getColumnInfo: createDeprecatedStub$3("getColumnInfo"),
|
|
684
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchUserSpaceInfo 替代 */
|
|
645
685
|
getUserProfileDetail: createDeprecatedStub$3("getUserProfileDetail"),
|
|
686
|
+
/** @deprecated 请使用 bilibiliFetcher.requestCaptchaFromVoucher 替代 */
|
|
646
687
|
applyVoucherCaptcha: createDeprecatedStub$3("applyVoucherCaptcha"),
|
|
688
|
+
/** @deprecated 请使用 bilibiliFetcher.validateCaptchaResult 替代 */
|
|
647
689
|
validateCaptcha: createDeprecatedStub$3("validateCaptcha"),
|
|
690
|
+
/** @deprecated 请使用 bilibiliFetcher.fetchVideoDanmaku 替代 */
|
|
648
691
|
getDanmaku: createDeprecatedStub$3("getDanmaku")
|
|
649
692
|
};
|
|
650
693
|
/**
|
|
@@ -655,7 +698,6 @@ const bilibili = {
|
|
|
655
698
|
const createBoundBilibiliApi = (_cookie, _requestConfig) => {
|
|
656
699
|
return { ...bilibili };
|
|
657
700
|
};
|
|
658
|
-
|
|
659
701
|
//#endregion
|
|
660
702
|
//#region src/model/events.ts
|
|
661
703
|
/**
|
|
@@ -674,8 +716,8 @@ var TypedEventEmitter = class extends node_events.EventEmitter {
|
|
|
674
716
|
* @param data - 事件数据
|
|
675
717
|
* @returns 是否有监听器处理了该事件
|
|
676
718
|
*/
|
|
677
|
-
emit(event, data
|
|
678
|
-
return super.emit(event, data
|
|
719
|
+
emit(event, data) {
|
|
720
|
+
return super.emit(event, data);
|
|
679
721
|
}
|
|
680
722
|
/**
|
|
681
723
|
* 注册事件监听器
|
|
@@ -737,9 +779,9 @@ const emitLog = (level, message, ...args) => {
|
|
|
737
779
|
* 发射 HTTP 请求事件
|
|
738
780
|
* @param data - 请求数据 (不含 timestamp)
|
|
739
781
|
*/
|
|
740
|
-
const emitHttpRequest = (data
|
|
782
|
+
const emitHttpRequest = (data) => {
|
|
741
783
|
amagiEvents.emit("http:request", {
|
|
742
|
-
...data
|
|
784
|
+
...data,
|
|
743
785
|
timestamp: /* @__PURE__ */ new Date()
|
|
744
786
|
});
|
|
745
787
|
};
|
|
@@ -747,9 +789,9 @@ const emitHttpRequest = (data$1) => {
|
|
|
747
789
|
* 发射 HTTP 响应事件
|
|
748
790
|
* @param data - 响应数据 (不含 timestamp)
|
|
749
791
|
*/
|
|
750
|
-
const emitHttpResponse = (data
|
|
792
|
+
const emitHttpResponse = (data) => {
|
|
751
793
|
amagiEvents.emit("http:response", {
|
|
752
|
-
...data
|
|
794
|
+
...data,
|
|
753
795
|
timestamp: /* @__PURE__ */ new Date()
|
|
754
796
|
});
|
|
755
797
|
};
|
|
@@ -757,9 +799,9 @@ const emitHttpResponse = (data$1) => {
|
|
|
757
799
|
* 发射网络重试事件
|
|
758
800
|
* @param data - 重试数据 (不含 timestamp)
|
|
759
801
|
*/
|
|
760
|
-
const emitNetworkRetry = (data
|
|
802
|
+
const emitNetworkRetry = (data) => {
|
|
761
803
|
amagiEvents.emit("network:retry", {
|
|
762
|
-
...data
|
|
804
|
+
...data,
|
|
763
805
|
timestamp: /* @__PURE__ */ new Date()
|
|
764
806
|
});
|
|
765
807
|
};
|
|
@@ -767,9 +809,9 @@ const emitNetworkRetry = (data$1) => {
|
|
|
767
809
|
* 发射网络错误事件
|
|
768
810
|
* @param data - 错误数据 (不含 timestamp)
|
|
769
811
|
*/
|
|
770
|
-
const emitNetworkError = (data
|
|
812
|
+
const emitNetworkError = (data) => {
|
|
771
813
|
amagiEvents.emit("network:error", {
|
|
772
|
-
...data
|
|
814
|
+
...data,
|
|
773
815
|
timestamp: /* @__PURE__ */ new Date()
|
|
774
816
|
});
|
|
775
817
|
};
|
|
@@ -777,9 +819,9 @@ const emitNetworkError = (data$1) => {
|
|
|
777
819
|
* 发射 API 成功事件
|
|
778
820
|
* @param data - 成功数据 (不含 timestamp)
|
|
779
821
|
*/
|
|
780
|
-
const emitApiSuccess = (data
|
|
822
|
+
const emitApiSuccess = (data) => {
|
|
781
823
|
amagiEvents.emit("api:success", {
|
|
782
|
-
...data
|
|
824
|
+
...data,
|
|
783
825
|
timestamp: /* @__PURE__ */ new Date()
|
|
784
826
|
});
|
|
785
827
|
};
|
|
@@ -787,9 +829,9 @@ const emitApiSuccess = (data$1) => {
|
|
|
787
829
|
* 发射 API 错误事件
|
|
788
830
|
* @param data - 错误数据 (不含 timestamp)
|
|
789
831
|
*/
|
|
790
|
-
const emitApiError = (data
|
|
832
|
+
const emitApiError = (data) => {
|
|
791
833
|
amagiEvents.emit("api:error", {
|
|
792
|
-
...data
|
|
834
|
+
...data,
|
|
793
835
|
timestamp: /* @__PURE__ */ new Date()
|
|
794
836
|
});
|
|
795
837
|
};
|
|
@@ -833,7 +875,6 @@ const emitLogDebug = (message, ...args) => {
|
|
|
833
875
|
const emitLogMark = (message, ...args) => {
|
|
834
876
|
emitLog("mark", message, ...args);
|
|
835
877
|
};
|
|
836
|
-
|
|
837
878
|
//#endregion
|
|
838
879
|
//#region src/validation/utils.ts
|
|
839
880
|
function smartNumber(errorMessage, minValue = 1, isInteger = false) {
|
|
@@ -864,7 +905,6 @@ const extractCreatorInfoFromHtml = (html) => {
|
|
|
864
905
|
return null;
|
|
865
906
|
}
|
|
866
907
|
};
|
|
867
|
-
|
|
868
908
|
//#endregion
|
|
869
909
|
//#region src/validation/bilibili.ts
|
|
870
910
|
/** 视频信息参数验证 */
|
|
@@ -958,7 +998,7 @@ const BilibiliBangumiInfoParamsSchema = zod.default.object({
|
|
|
958
998
|
methodType: zod.default.literal("bangumiInfo", { error: "方法类型必须是\"bangumiInfo\"" }),
|
|
959
999
|
ep_id: zod.default.string({ error: "番剧EP ID必须是字符串" }).min(1, { error: "番剧EP ID不能为空" }).optional(),
|
|
960
1000
|
season_id: zod.default.string({ error: "番剧季度ID必须是字符串" }).optional()
|
|
961
|
-
}).refine((data
|
|
1001
|
+
}).refine((data) => data.ep_id ?? data.season_id, {
|
|
962
1002
|
error: "ep_id 和 season_id 至少需要提供一个",
|
|
963
1003
|
path: ["ep_id"]
|
|
964
1004
|
});
|
|
@@ -1098,7 +1138,6 @@ const BilibiliMethodRoutes = {
|
|
|
1098
1138
|
validateCaptcha: "/validate_captcha",
|
|
1099
1139
|
videoDanmaku: "/fetch_danmaku"
|
|
1100
1140
|
};
|
|
1101
|
-
|
|
1102
1141
|
//#endregion
|
|
1103
1142
|
//#region src/validation/douyin.ts
|
|
1104
1143
|
/** 作品参数验证 */
|
|
@@ -1187,14 +1226,14 @@ const DouyinDanmakuParamsSchema = zod.default.object({
|
|
|
1187
1226
|
start_time: zod.default.coerce.number({ error: "开始时间必须是数字" }).int({ error: "开始时间必须是整数" }).min(0, { error: "开始时间不能小于0" }).optional(),
|
|
1188
1227
|
end_time: zod.default.coerce.number({ error: "结束时间必须是数字" }).int({ error: "结束时间必须是整数" }).min(0, { error: "结束时间不能小于0" }).optional(),
|
|
1189
1228
|
duration: zod.default.coerce.number({ error: "视频时长必须是数字" }).int({ error: "视频时长必须是整数" }).min(0, { error: "视频时长不能小于0" })
|
|
1190
|
-
}).refine((data
|
|
1191
|
-
if (data
|
|
1229
|
+
}).refine((data) => {
|
|
1230
|
+
if (data.end_time !== void 0) return data.end_time <= data.duration;
|
|
1192
1231
|
return true;
|
|
1193
1232
|
}, {
|
|
1194
1233
|
error: "获取弹幕区间的结束时间不能超过视频总时长",
|
|
1195
1234
|
path: ["end_time"]
|
|
1196
|
-
}).refine((data
|
|
1197
|
-
if (data
|
|
1235
|
+
}).refine((data) => {
|
|
1236
|
+
if (data.start_time !== void 0 && data.end_time !== void 0) return data.start_time < data.end_time;
|
|
1198
1237
|
return true;
|
|
1199
1238
|
}, {
|
|
1200
1239
|
error: "获取弹幕区间的开始时间必须小于结束时间",
|
|
@@ -1244,7 +1283,6 @@ const DouyinMethodRoutes = {
|
|
|
1244
1283
|
danmakuList: "/fetch_work_danmaku",
|
|
1245
1284
|
loginQrcode: "/fetch_login_qrcode"
|
|
1246
1285
|
};
|
|
1247
|
-
|
|
1248
1286
|
//#endregion
|
|
1249
1287
|
//#region src/validation/kuaishou.ts
|
|
1250
1288
|
/**
|
|
@@ -1310,14 +1348,195 @@ const KuaishouMethodRoutes = {
|
|
|
1310
1348
|
liveRoomInfo: "/fetch_live_room_info",
|
|
1311
1349
|
emojiList: "/fetch_emoji_list"
|
|
1312
1350
|
};
|
|
1313
|
-
|
|
1351
|
+
//#endregion
|
|
1352
|
+
//#region src/platform/xiaohongshu/sign/config.ts
|
|
1353
|
+
/** 初始化签名配置。 */
|
|
1354
|
+
const createXiaohongshuCryptoConfig = () => new _ikenxuan_xhshow_ts.CryptoConfig().withOverrides({
|
|
1355
|
+
DATA_WEB_BUILD: "6.12.3",
|
|
1356
|
+
SIGNATURE_DATA_TEMPLATE: {
|
|
1357
|
+
x0: "4.3.5",
|
|
1358
|
+
x1: "xhs-pc-web",
|
|
1359
|
+
x2: "Windows",
|
|
1360
|
+
x3: "",
|
|
1361
|
+
x4: ""
|
|
1362
|
+
},
|
|
1363
|
+
SIGNATURE_XSCOMMON_TEMPLATE: {
|
|
1364
|
+
s0: 5,
|
|
1365
|
+
s1: "",
|
|
1366
|
+
x0: "1",
|
|
1367
|
+
x1: "4.3.5",
|
|
1368
|
+
x2: "Windows",
|
|
1369
|
+
x3: "xhs-pc-web",
|
|
1370
|
+
x4: "6.12.3",
|
|
1371
|
+
x5: "",
|
|
1372
|
+
x6: "",
|
|
1373
|
+
x7: "",
|
|
1374
|
+
x8: "",
|
|
1375
|
+
x9: -596800761,
|
|
1376
|
+
x10: 0,
|
|
1377
|
+
x11: "normal"
|
|
1378
|
+
}
|
|
1379
|
+
});
|
|
1380
|
+
//#endregion
|
|
1381
|
+
//#region src/platform/xiaohongshu/sign/guestCookie.ts
|
|
1382
|
+
/** @see https://github.com/Cialle/RedCrack */
|
|
1383
|
+
/** 小红书 Web 端游客会话初始化使用的浏览器请求头。 */
|
|
1384
|
+
const GUEST_HEADERS = {
|
|
1385
|
+
accept: "application/json, text/plain, */*",
|
|
1386
|
+
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
|
1387
|
+
"content-type": "application/json;charset=UTF-8",
|
|
1388
|
+
origin: "https://www.xiaohongshu.com",
|
|
1389
|
+
priority: "u=1, i",
|
|
1390
|
+
referer: "https://www.xiaohongshu.com/",
|
|
1391
|
+
"sec-ch-ua": "\"Microsoft Edge\";v=\"141\", \"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"141\"",
|
|
1392
|
+
"sec-ch-ua-mobile": "?0",
|
|
1393
|
+
"sec-ch-ua-platform": "\"Windows\"",
|
|
1394
|
+
"sec-fetch-dest": "empty",
|
|
1395
|
+
"sec-fetch-mode": "cors",
|
|
1396
|
+
"sec-fetch-site": "same-site",
|
|
1397
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0"
|
|
1398
|
+
};
|
|
1399
|
+
/** 生成 a1 随机段时使用的 Web 端字符集。 */
|
|
1400
|
+
const COOKIE_RANDOM_CHARS = "abcdefghijklmnopqrstuvwxyz1234567890";
|
|
1401
|
+
/** 将 Cookie Jar 序列化为可直接写入 HTTP Cookie 请求头的字符串。 */
|
|
1402
|
+
const toCookieString = (cookies) => Object.entries(cookies).map(([key, value]) => `${key}=${value}`).join("; ");
|
|
1403
|
+
/** 将响应头中的 Set-Cookie 字段合并到当前游客会话的 Cookie Jar。 */
|
|
1404
|
+
const updateCookiesFromResponse = (cookies, setCookie) => {
|
|
1405
|
+
const headers = Array.isArray(setCookie) ? setCookie : setCookie ? [setCookie] : [];
|
|
1406
|
+
for (const header of headers) {
|
|
1407
|
+
const [nameValue] = header.split(";", 1);
|
|
1408
|
+
const separatorIndex = nameValue.indexOf("=");
|
|
1409
|
+
if (separatorIndex > 0) cookies[nameValue.slice(0, separatorIndex).trim()] = nameValue.slice(separatorIndex + 1).trim();
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
/** 按小红书 Web 端规则生成 a1,以及由 a1 派生的 webId。 */
|
|
1413
|
+
const generateA1AndWebId = () => {
|
|
1414
|
+
const source = `${Date.now().toString(16)}${Array.from((0, node_crypto.randomBytes)(30), (byte) => COOKIE_RANDOM_CHARS[byte % 36]).join("")}5000`;
|
|
1415
|
+
const a1 = `${source}${crc32(source)}`.slice(0, 52);
|
|
1416
|
+
return {
|
|
1417
|
+
a1,
|
|
1418
|
+
webId: (0, node_crypto.createHash)("md5").update(a1).digest("hex")
|
|
1419
|
+
};
|
|
1420
|
+
};
|
|
1421
|
+
/** 计算与浏览器端实现兼容的无符号 CRC32 校验值。 */
|
|
1422
|
+
const crc32 = (input) => {
|
|
1423
|
+
let value = 4294967295;
|
|
1424
|
+
for (const byte of Buffer.from(input)) {
|
|
1425
|
+
value ^= byte;
|
|
1426
|
+
for (let bit = 0; bit < 8; bit += 1) value = value & 1 ? value >>> 1 ^ 3988292384 : value >>> 1;
|
|
1427
|
+
}
|
|
1428
|
+
return (value ^ 4294967295) >>> 0;
|
|
1429
|
+
};
|
|
1430
|
+
/** 从 scripting 接口返回的 VMP 数据中解码 websectiga Cookie。 */
|
|
1431
|
+
const generateWebsectiga = (payload) => {
|
|
1432
|
+
const bMatch = payload.match(/"b":"(.*?)",/);
|
|
1433
|
+
const dMatch = payload.match(/"d":(.*?)\}\)/);
|
|
1434
|
+
if (!bMatch || !dMatch) throw new Error("小红书 scripting 响应格式异常,无法生成 websectiga");
|
|
1435
|
+
const decoderData = JSON.parse(dMatch[1]);
|
|
1436
|
+
const encoded = Buffer.from(bMatch[1], "base64").toString("utf8");
|
|
1437
|
+
const logicList = [];
|
|
1438
|
+
for (let index = 0; index < encoded.length; index += 5) logicList.push(Array.from(encoded.slice(index, index + 5), (char) => char.charCodeAt(0) - 1));
|
|
1439
|
+
const start = decoderData[92];
|
|
1440
|
+
const end = decoderData[93];
|
|
1441
|
+
const target = logicList.slice(start, end + 1);
|
|
1442
|
+
const key = Array.from({ length: 64 }, (_, index) => {
|
|
1443
|
+
const item = target[675 + index * 2];
|
|
1444
|
+
if (!item) throw new Error("小红书 scripting 响应缺少 websectiga 解码数据");
|
|
1445
|
+
return decoderData[item[2]];
|
|
1446
|
+
});
|
|
1447
|
+
return Array.from({ length: 8 }, (_, group) => {
|
|
1448
|
+
const offset = 56 - group * 8;
|
|
1449
|
+
return String.fromCharCode(...key.slice(offset, offset + 8));
|
|
1450
|
+
}).join("");
|
|
1451
|
+
};
|
|
1452
|
+
/** 将浏览器指纹编码为 webprofile 接口要求的 DES-ECB profileData。 */
|
|
1453
|
+
const encryptProfileData = (fingerprint, desKey) => {
|
|
1454
|
+
const encoded = Buffer.from(JSON.stringify(fingerprint)).toString("base64");
|
|
1455
|
+
const blockSize = 8;
|
|
1456
|
+
const padding = blockSize - encoded.length % blockSize;
|
|
1457
|
+
const plaintext = Buffer.concat([Buffer.from(encoded), Buffer.alloc(padding)]);
|
|
1458
|
+
const cipher = (0, node_crypto.createCipheriv)("des-ede3", Buffer.from(desKey.repeat(3)), null);
|
|
1459
|
+
cipher.setAutoPadding(false);
|
|
1460
|
+
return Buffer.concat([cipher.update(plaintext), cipher.final()]).toString("hex");
|
|
1461
|
+
};
|
|
1462
|
+
/** 将 scripting 的 JSON 或 JSONP 响应统一还原为结构化数据。 */
|
|
1463
|
+
const unwrapScriptingResponse = (data) => {
|
|
1464
|
+
if (typeof data === "string") {
|
|
1465
|
+
const json = data.match(/^[^(]+\((.*)\)$/s)?.[1];
|
|
1466
|
+
return JSON.parse(json ?? data);
|
|
1467
|
+
}
|
|
1468
|
+
return data;
|
|
1469
|
+
};
|
|
1470
|
+
/**
|
|
1471
|
+
* 创建小红书 Web 端游客会话 Cookie。
|
|
1472
|
+
*
|
|
1473
|
+
* 该流程对应 Web 端首次访问时的 Cookie 初始化:生成 a1/webId,完成
|
|
1474
|
+
* scripting、webprofile 与 activate 三个会话请求,并返回最终 Cookie 字符串。
|
|
1475
|
+
*/
|
|
1476
|
+
const createXiaohongshuGuestCookie = async (requestConfig) => {
|
|
1477
|
+
const cryptoConfig = createXiaohongshuCryptoConfig();
|
|
1478
|
+
const signer = new _ikenxuan_xhshow_ts.Xhshow(cryptoConfig);
|
|
1479
|
+
const cookies = {
|
|
1480
|
+
...generateA1AndWebId(),
|
|
1481
|
+
webBuild: cryptoConfig.DATA_WEB_BUILD,
|
|
1482
|
+
xsecappid: "xhs-pc-web",
|
|
1483
|
+
loadts: String(Date.now()),
|
|
1484
|
+
abRequestId: (0, node_crypto.randomUUID)()
|
|
1485
|
+
};
|
|
1486
|
+
const { headers: requestHeaders, params: _params, ...transportConfig } = requestConfig ?? {};
|
|
1487
|
+
/** 发送会话初始化请求,并将响应中的 Set-Cookie 合并回当前 Cookie Jar。 */
|
|
1488
|
+
const request = async (url, data, signed = false) => {
|
|
1489
|
+
const signatureHeaders = signed ? signer.signHeadersPost(new URL(url).pathname, cookies, "xhs-pc-web", data) : {};
|
|
1490
|
+
const response = await (0, axios.default)({
|
|
1491
|
+
...transportConfig,
|
|
1492
|
+
method: "POST",
|
|
1493
|
+
url,
|
|
1494
|
+
data,
|
|
1495
|
+
validateStatus: () => true,
|
|
1496
|
+
headers: {
|
|
1497
|
+
...GUEST_HEADERS,
|
|
1498
|
+
...requestHeaders,
|
|
1499
|
+
...signatureHeaders,
|
|
1500
|
+
Cookie: toCookieString(cookies)
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
updateCookiesFromResponse(cookies, response.headers["set-cookie"]);
|
|
1504
|
+
if (response.status < 200 || response.status >= 300) throw new Error(`小红书游客会话初始化失败:${url} 返回 HTTP ${response.status}`);
|
|
1505
|
+
return response.data;
|
|
1506
|
+
};
|
|
1507
|
+
const scriptingData = unwrapScriptingResponse(await request("https://as.xiaohongshu.com/api/sec/v1/scripting", {
|
|
1508
|
+
callFrom: "web",
|
|
1509
|
+
callback: "seccallback"
|
|
1510
|
+
})).data;
|
|
1511
|
+
if (!scriptingData?.data || !scriptingData.secPoisonId) throw new Error("小红书 scripting 响应缺少游客会话数据");
|
|
1512
|
+
cookies.websectiga = generateWebsectiga(scriptingData.data);
|
|
1513
|
+
cookies.sec_poison_id = scriptingData.secPoisonId;
|
|
1514
|
+
const fingerprint = new _ikenxuan_xhshow_ts.FingerprintGenerator(cryptoConfig).generate(cookies, GUEST_HEADERS["user-agent"]);
|
|
1515
|
+
await request(cryptoConfig.GID_URL, {
|
|
1516
|
+
platform: cryptoConfig.DATA_PLATFORM,
|
|
1517
|
+
profileData: encryptProfileData(fingerprint, cryptoConfig.DES_KEY),
|
|
1518
|
+
sdkVersion: cryptoConfig.DATA_SDK_VERSION,
|
|
1519
|
+
svn: cryptoConfig.DATA_SVN
|
|
1520
|
+
}, true);
|
|
1521
|
+
await request("https://edith.xiaohongshu.com/api/sns/web/v1/login/activate", {}, true);
|
|
1522
|
+
if (!cookies.web_session) throw new Error("小红书游客会话初始化失败:未获取到 web_session");
|
|
1523
|
+
return toCookieString(cookies);
|
|
1524
|
+
};
|
|
1314
1525
|
//#endregion
|
|
1315
1526
|
//#region src/platform/xiaohongshu/sign/index.ts
|
|
1316
1527
|
/**
|
|
1317
1528
|
* 小红书签名算法类
|
|
1318
1529
|
*/
|
|
1319
1530
|
var xiaohongshuSign = class {
|
|
1320
|
-
static client = new _ikenxuan_xhshow_ts.Xhshow();
|
|
1531
|
+
static client = new _ikenxuan_xhshow_ts.Xhshow(createXiaohongshuCryptoConfig());
|
|
1532
|
+
/**
|
|
1533
|
+
* 创建包含 web_session 的小红书 Web 端游客 Cookie。
|
|
1534
|
+
*
|
|
1535
|
+
* `requestConfig` 会透传到游客会话初始化请求,可用于配置代理、超时等传输参数。
|
|
1536
|
+
*/
|
|
1537
|
+
static createGuestCookie(requestConfig) {
|
|
1538
|
+
return createXiaohongshuGuestCookie(requestConfig);
|
|
1539
|
+
}
|
|
1321
1540
|
/**
|
|
1322
1541
|
* 生成GET请求的X-S签名
|
|
1323
1542
|
* @param path - API路径
|
|
@@ -1377,44 +1596,43 @@ var xiaohongshuSign = class {
|
|
|
1377
1596
|
*/
|
|
1378
1597
|
static getSearchId = () => (BigInt(Date.now()) << 64n) + BigInt(Math.floor(Math.random() * 2147483646)).toString(36);
|
|
1379
1598
|
};
|
|
1380
|
-
|
|
1381
1599
|
//#endregion
|
|
1382
1600
|
//#region src/platform/xiaohongshu/API.ts
|
|
1383
1601
|
/**
|
|
1384
1602
|
* 搜索排序类型枚举
|
|
1385
1603
|
*/
|
|
1386
|
-
let SearchSortType = /* @__PURE__ */ function(SearchSortType
|
|
1604
|
+
let SearchSortType = /* @__PURE__ */ function(SearchSortType) {
|
|
1387
1605
|
/**
|
|
1388
1606
|
* 默认排序
|
|
1389
1607
|
*/
|
|
1390
|
-
SearchSortType
|
|
1608
|
+
SearchSortType["GENERAL"] = "general";
|
|
1391
1609
|
/**
|
|
1392
1610
|
* 最受欢迎(按热度降序)
|
|
1393
1611
|
*/
|
|
1394
|
-
SearchSortType
|
|
1612
|
+
SearchSortType["MOST_POPULAR"] = "popularity_descending";
|
|
1395
1613
|
/**
|
|
1396
1614
|
* 最新发布(按时间降序)
|
|
1397
1615
|
*/
|
|
1398
|
-
SearchSortType
|
|
1399
|
-
return SearchSortType
|
|
1616
|
+
SearchSortType["LATEST"] = "time_descending";
|
|
1617
|
+
return SearchSortType;
|
|
1400
1618
|
}({});
|
|
1401
1619
|
/**
|
|
1402
1620
|
* 搜索笔记类型枚举
|
|
1403
1621
|
*/
|
|
1404
|
-
let SearchNoteType = /* @__PURE__ */ function(SearchNoteType
|
|
1622
|
+
let SearchNoteType = /* @__PURE__ */ function(SearchNoteType) {
|
|
1405
1623
|
/**
|
|
1406
1624
|
* 默认(全部类型)
|
|
1407
1625
|
*/
|
|
1408
|
-
SearchNoteType
|
|
1626
|
+
SearchNoteType[SearchNoteType["ALL"] = 0] = "ALL";
|
|
1409
1627
|
/**
|
|
1410
1628
|
* 仅视频
|
|
1411
1629
|
*/
|
|
1412
|
-
SearchNoteType
|
|
1630
|
+
SearchNoteType[SearchNoteType["VIDEO"] = 1] = "VIDEO";
|
|
1413
1631
|
/**
|
|
1414
1632
|
* 仅图片
|
|
1415
1633
|
*/
|
|
1416
|
-
SearchNoteType
|
|
1417
|
-
return SearchNoteType
|
|
1634
|
+
SearchNoteType[SearchNoteType["IMAGE"] = 2] = "IMAGE";
|
|
1635
|
+
return SearchNoteType;
|
|
1418
1636
|
}({});
|
|
1419
1637
|
/**
|
|
1420
1638
|
* 构建查询字符串
|
|
@@ -1428,17 +1646,22 @@ const buildQueryString$1 = (params) => {
|
|
|
1428
1646
|
* 小红书API地址配置
|
|
1429
1647
|
*/
|
|
1430
1648
|
const xiaohongshuApiUrls = {
|
|
1431
|
-
|
|
1649
|
+
/**
|
|
1650
|
+
* 获取首页推荐数据的接口地址
|
|
1651
|
+
* @param data - 请求参数
|
|
1652
|
+
* @returns 完整的接口URL
|
|
1653
|
+
*/
|
|
1654
|
+
homeFeed(data = {}) {
|
|
1432
1655
|
return {
|
|
1433
1656
|
apiPath: "/api/sns/web/v1/homefeed",
|
|
1434
1657
|
Url: "https://edith.xiaohongshu.com/api/sns/web/v1/homefeed",
|
|
1435
1658
|
Body: {
|
|
1436
|
-
cursor_score: data
|
|
1437
|
-
num: data
|
|
1438
|
-
refresh_type: data
|
|
1439
|
-
note_index: data
|
|
1440
|
-
category: data
|
|
1441
|
-
search_key: data
|
|
1659
|
+
cursor_score: data.cursor_score ?? "1.7599348899670024E9",
|
|
1660
|
+
num: data.num ?? 33,
|
|
1661
|
+
refresh_type: data.refresh_type ?? 3,
|
|
1662
|
+
note_index: data.note_index ?? 33,
|
|
1663
|
+
category: data.category ?? "homefeed_recommend",
|
|
1664
|
+
search_key: data.search_key ?? "",
|
|
1442
1665
|
image_formats: [
|
|
1443
1666
|
"jpg",
|
|
1444
1667
|
"webp",
|
|
@@ -1447,12 +1670,17 @@ const xiaohongshuApiUrls = {
|
|
|
1447
1670
|
}
|
|
1448
1671
|
};
|
|
1449
1672
|
},
|
|
1450
|
-
|
|
1673
|
+
/**
|
|
1674
|
+
* 获取单个笔记数据的接口地址
|
|
1675
|
+
* @param data - 请求参数
|
|
1676
|
+
* @returns 完整的接口URL
|
|
1677
|
+
*/
|
|
1678
|
+
noteDetail(data) {
|
|
1451
1679
|
return {
|
|
1452
1680
|
apiPath: "/api/sns/web/v1/feed",
|
|
1453
1681
|
Url: "https://edith.xiaohongshu.com/api/sns/web/v1/feed",
|
|
1454
1682
|
Body: {
|
|
1455
|
-
source_note_id: data
|
|
1683
|
+
source_note_id: data.note_id,
|
|
1456
1684
|
image_formats: [
|
|
1457
1685
|
"jpg",
|
|
1458
1686
|
"webp",
|
|
@@ -1460,38 +1688,53 @@ const xiaohongshuApiUrls = {
|
|
|
1460
1688
|
],
|
|
1461
1689
|
extra: { need_body_topic: "1" },
|
|
1462
1690
|
xsec_source: "pc_feed",
|
|
1463
|
-
xsec_token: data
|
|
1691
|
+
xsec_token: data.xsec_token
|
|
1464
1692
|
}
|
|
1465
1693
|
};
|
|
1466
1694
|
},
|
|
1467
|
-
|
|
1695
|
+
/**
|
|
1696
|
+
* 获取评论数据的接口地址
|
|
1697
|
+
* @param data - 请求参数
|
|
1698
|
+
* @returns 完整的接口URL
|
|
1699
|
+
*/
|
|
1700
|
+
noteComments(data) {
|
|
1468
1701
|
return {
|
|
1469
1702
|
apiPath: "/api/sns/web/v2/comment/page",
|
|
1470
1703
|
Url: `https://edith.xiaohongshu.com/api/sns/web/v2/comment/page?${buildQueryString$1({
|
|
1471
|
-
note_id: data
|
|
1472
|
-
cursor: data
|
|
1704
|
+
note_id: data.note_id,
|
|
1705
|
+
cursor: data.cursor ?? "",
|
|
1473
1706
|
image_formats: [
|
|
1474
1707
|
"jpg",
|
|
1475
1708
|
"webp",
|
|
1476
1709
|
"avif"
|
|
1477
1710
|
].join(","),
|
|
1478
|
-
xsec_token: data
|
|
1711
|
+
xsec_token: data.xsec_token
|
|
1479
1712
|
})}`
|
|
1480
1713
|
};
|
|
1481
1714
|
},
|
|
1482
|
-
|
|
1715
|
+
/**
|
|
1716
|
+
* 获取用户数据的接口地址
|
|
1717
|
+
* @param data - 请求参数
|
|
1718
|
+
* @returns 完整的接口URL
|
|
1719
|
+
*/
|
|
1720
|
+
userProfile(data) {
|
|
1483
1721
|
return {
|
|
1484
1722
|
apiPath: "/api/sns/web/v1/user/otherinfo",
|
|
1485
|
-
Url: `https://www.xiaohongshu.com/user/profile/${data
|
|
1723
|
+
Url: `https://www.xiaohongshu.com/user/profile/${data.user_id}`
|
|
1486
1724
|
};
|
|
1487
1725
|
},
|
|
1488
|
-
|
|
1726
|
+
/**
|
|
1727
|
+
* 获取用户笔记数据的接口地址
|
|
1728
|
+
* @param data - 请求参数
|
|
1729
|
+
* @returns 完整的接口URL
|
|
1730
|
+
*/
|
|
1731
|
+
userNoteList(data) {
|
|
1489
1732
|
return {
|
|
1490
1733
|
apiPath: "/api/sns/web/v1/user_posted",
|
|
1491
1734
|
Url: `https://edith.xiaohongshu.com/api/sns/web/v1/user_posted?${buildQueryString$1({
|
|
1492
|
-
user_id: data
|
|
1493
|
-
cursor: data
|
|
1494
|
-
num: data
|
|
1735
|
+
user_id: data.user_id,
|
|
1736
|
+
cursor: data.cursor ?? "",
|
|
1737
|
+
num: data.num ?? 30,
|
|
1495
1738
|
image_formats: [
|
|
1496
1739
|
"jpg",
|
|
1497
1740
|
"webp",
|
|
@@ -1501,21 +1744,31 @@ const xiaohongshuApiUrls = {
|
|
|
1501
1744
|
})}`
|
|
1502
1745
|
};
|
|
1503
1746
|
},
|
|
1504
|
-
|
|
1747
|
+
/**
|
|
1748
|
+
* 获取笔记表情列表的接口地址
|
|
1749
|
+
* @param data - 请求参数
|
|
1750
|
+
* @returns 完整的接口URL
|
|
1751
|
+
*/
|
|
1752
|
+
emojiList(_data) {
|
|
1505
1753
|
return {
|
|
1506
1754
|
apiPath: "/api/im/redmoji/detail",
|
|
1507
1755
|
Url: "https://edith.xiaohongshu.com/api/im/redmoji/detail"
|
|
1508
1756
|
};
|
|
1509
1757
|
},
|
|
1510
|
-
|
|
1758
|
+
/**
|
|
1759
|
+
* 搜索笔记的接口地址
|
|
1760
|
+
* @param data - 请求参数
|
|
1761
|
+
* @returns 完整的接口URL
|
|
1762
|
+
*/
|
|
1763
|
+
searchNotes(data) {
|
|
1511
1764
|
return {
|
|
1512
1765
|
apiPath: "/api/sns/web/v1/search/notes",
|
|
1513
1766
|
Body: {
|
|
1514
|
-
keyword: data
|
|
1515
|
-
page: data
|
|
1516
|
-
page_size: data
|
|
1517
|
-
sort:
|
|
1518
|
-
note_type:
|
|
1767
|
+
keyword: data.keyword,
|
|
1768
|
+
page: data.page ?? 1,
|
|
1769
|
+
page_size: data.page_size ?? 20,
|
|
1770
|
+
sort: "general",
|
|
1771
|
+
note_type: 0,
|
|
1519
1772
|
search_id: xiaohongshuSign.getSearchId(),
|
|
1520
1773
|
image_formats: [
|
|
1521
1774
|
"jpg",
|
|
@@ -1534,82 +1787,53 @@ const xiaohongshuApiUrls = {
|
|
|
1534
1787
|
const createXiaohongshuApiUrls = () => {
|
|
1535
1788
|
return xiaohongshuApiUrls;
|
|
1536
1789
|
};
|
|
1537
|
-
|
|
1538
1790
|
//#endregion
|
|
1539
1791
|
//#region src/validation/xiaohongshu.ts
|
|
1540
1792
|
const SearchSortTypeValues = Object.values(SearchSortType).filter((v) => typeof v === "string");
|
|
1541
1793
|
const SearchNoteTypeValues = Object.values(SearchNoteType).filter((v) => typeof v === "number");
|
|
1542
1794
|
/**
|
|
1543
|
-
* 小红书首页推荐数据参数验证模式
|
|
1544
|
-
*/
|
|
1545
|
-
const HomeFeedParamsSchema = zod.default.object({
|
|
1546
|
-
methodType: zod.default.literal("homeFeed", { error: "methodType must be \"homeFeed\"" }),
|
|
1547
|
-
cursor_score: zod.default.string({ error: "cursor_score must be a string" }).optional(),
|
|
1548
|
-
num: zod.default.coerce.number({ error: "num must be a number" }).int({ error: "num must be an integer" }).min(1, { error: "num cannot be less than 1" }).max(100, { error: "num cannot be greater than 100" }).optional(),
|
|
1549
|
-
refresh_type: zod.default.coerce.number({ error: "refresh_type must be a number" }).int({ error: "refresh_type must be an integer" }).optional(),
|
|
1550
|
-
note_index: zod.default.coerce.number({ error: "note_index must be a number" }).int({ error: "note_index must be an integer" }).optional(),
|
|
1551
|
-
category: zod.default.string({ error: "category must be a string" }).optional(),
|
|
1552
|
-
search_key: zod.default.string({ error: "search_key must be a string" }).optional()
|
|
1553
|
-
});
|
|
1554
|
-
/**
|
|
1555
|
-
* 小红书单个笔记数据参数验证模式
|
|
1556
|
-
*/
|
|
1557
|
-
const NoteParamsSchema = zod.default.object({
|
|
1558
|
-
methodType: zod.default.literal("noteDetail", { error: "methodType must be \"noteDetail\"" }),
|
|
1559
|
-
note_id: zod.default.string({ error: "note_id must be a string" }),
|
|
1560
|
-
xsec_token: zod.default.string({ error: "xsec_token must be a string" })
|
|
1561
|
-
});
|
|
1562
|
-
/**
|
|
1563
|
-
* 小红书评论数据参数验证模式
|
|
1564
|
-
*/
|
|
1565
|
-
const CommentParamsSchema = zod.default.object({
|
|
1566
|
-
methodType: zod.default.literal("noteComments", { error: "methodType must be \"noteComments\"" }),
|
|
1567
|
-
note_id: zod.default.string({ error: "note_id must be a string" }),
|
|
1568
|
-
cursor: zod.default.string({ error: "cursor must be a string" }).optional(),
|
|
1569
|
-
xsec_token: zod.default.string({ error: "xsec_token must be a string" })
|
|
1570
|
-
});
|
|
1571
|
-
/**
|
|
1572
|
-
* 小红书用户数据参数验证模式
|
|
1573
|
-
*/
|
|
1574
|
-
const UserParamsSchema = zod.default.object({
|
|
1575
|
-
methodType: zod.default.literal("userProfile", { error: "methodType must be \"userProfile\"" }),
|
|
1576
|
-
user_id: zod.default.string({ error: "user_id must be a string" })
|
|
1577
|
-
});
|
|
1578
|
-
/**
|
|
1579
|
-
* 小红书用户笔记数据参数验证模式
|
|
1580
|
-
*/
|
|
1581
|
-
const UserNoteParamsSchema = zod.default.object({
|
|
1582
|
-
methodType: zod.default.literal("userNoteList", { error: "methodType must be \"userNoteList\"" }),
|
|
1583
|
-
user_id: zod.default.string({ error: "user_id must be a string" }),
|
|
1584
|
-
cursor: zod.default.string({ error: "cursor must be a string" }).optional(),
|
|
1585
|
-
num: zod.default.coerce.number({ error: "num must be a number" }).int({ error: "num must be an integer" }).min(1, { error: "num cannot be less than 1" }).max(100, { error: "num cannot be greater than 100" }).optional()
|
|
1586
|
-
});
|
|
1587
|
-
/**
|
|
1588
|
-
* 小红书表情列表参数验证模式
|
|
1589
|
-
*/
|
|
1590
|
-
const EmojiListParamsSchema = zod.default.object({ methodType: zod.default.literal("emojiList", { error: "methodType must be \"emojiList\"" }) });
|
|
1591
|
-
/**
|
|
1592
|
-
* 小红书搜索笔记参数验证模式
|
|
1593
|
-
*/
|
|
1594
|
-
const SearchNoteParamsSchema = zod.default.object({
|
|
1595
|
-
methodType: zod.default.literal("searchNotes", { error: "methodType must be \"searchNotes\"" }),
|
|
1596
|
-
keyword: zod.default.string({ error: "keyword must be a string" }),
|
|
1597
|
-
page: zod.default.coerce.number({ error: "page must be a number" }).int({ error: "page must be an integer" }).min(1, { error: "page cannot be less than 1" }).optional(),
|
|
1598
|
-
page_size: zod.default.coerce.number({ error: "page_size must be a number" }).int({ error: "page_size must be an integer" }).min(1, { error: "page_size cannot be less than 1" }).max(100, { error: "page_size cannot be greater than 100" }).optional(),
|
|
1599
|
-
sort: zod.default.enum(SearchSortTypeValues, { error: "Invalid sort type" }).optional(),
|
|
1600
|
-
note_type: zod.default.coerce.number({ error: "note_type must be a number" }).int({ error: "note_type must be an integer" }).refine((val) => SearchNoteTypeValues.includes(val), { message: "Invalid note type" }).optional()
|
|
1601
|
-
});
|
|
1602
|
-
/**
|
|
1603
1795
|
* 小红书验证模式映射
|
|
1604
1796
|
*/
|
|
1605
1797
|
const XiaohongshuValidationSchemas = {
|
|
1606
|
-
homeFeed:
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1798
|
+
homeFeed: zod.default.object({
|
|
1799
|
+
methodType: zod.default.literal("homeFeed", { error: "methodType must be \"homeFeed\"" }),
|
|
1800
|
+
cursor_score: zod.default.string({ error: "cursor_score must be a string" }).optional(),
|
|
1801
|
+
num: zod.default.coerce.number({ error: "num must be a number" }).int({ error: "num must be an integer" }).min(1, { error: "num cannot be less than 1" }).max(100, { error: "num cannot be greater than 100" }).optional(),
|
|
1802
|
+
refresh_type: zod.default.coerce.number({ error: "refresh_type must be a number" }).int({ error: "refresh_type must be an integer" }).optional(),
|
|
1803
|
+
note_index: zod.default.coerce.number({ error: "note_index must be a number" }).int({ error: "note_index must be an integer" }).optional(),
|
|
1804
|
+
category: zod.default.string({ error: "category must be a string" }).optional(),
|
|
1805
|
+
search_key: zod.default.string({ error: "search_key must be a string" }).optional()
|
|
1806
|
+
}),
|
|
1807
|
+
noteDetail: zod.default.object({
|
|
1808
|
+
methodType: zod.default.literal("noteDetail", { error: "methodType must be \"noteDetail\"" }),
|
|
1809
|
+
note_id: zod.default.string({ error: "note_id must be a string" }),
|
|
1810
|
+
xsec_token: zod.default.string({ error: "xsec_token must be a string" })
|
|
1811
|
+
}),
|
|
1812
|
+
noteComments: zod.default.object({
|
|
1813
|
+
methodType: zod.default.literal("noteComments", { error: "methodType must be \"noteComments\"" }),
|
|
1814
|
+
note_id: zod.default.string({ error: "note_id must be a string" }),
|
|
1815
|
+
cursor: zod.default.string({ error: "cursor must be a string" }).optional(),
|
|
1816
|
+
xsec_token: zod.default.string({ error: "xsec_token must be a string" })
|
|
1817
|
+
}),
|
|
1818
|
+
userProfile: zod.default.object({
|
|
1819
|
+
methodType: zod.default.literal("userProfile", { error: "methodType must be \"userProfile\"" }),
|
|
1820
|
+
user_id: zod.default.string({ error: "user_id must be a string" })
|
|
1821
|
+
}),
|
|
1822
|
+
userNoteList: zod.default.object({
|
|
1823
|
+
methodType: zod.default.literal("userNoteList", { error: "methodType must be \"userNoteList\"" }),
|
|
1824
|
+
user_id: zod.default.string({ error: "user_id must be a string" }),
|
|
1825
|
+
cursor: zod.default.string({ error: "cursor must be a string" }).optional(),
|
|
1826
|
+
num: zod.default.coerce.number({ error: "num must be a number" }).int({ error: "num must be an integer" }).min(1, { error: "num cannot be less than 1" }).max(100, { error: "num cannot be greater than 100" }).optional()
|
|
1827
|
+
}),
|
|
1828
|
+
emojiList: zod.default.object({ methodType: zod.default.literal("emojiList", { error: "methodType must be \"emojiList\"" }) }),
|
|
1829
|
+
searchNotes: zod.default.object({
|
|
1830
|
+
methodType: zod.default.literal("searchNotes", { error: "methodType must be \"searchNotes\"" }),
|
|
1831
|
+
keyword: zod.default.string({ error: "keyword must be a string" }),
|
|
1832
|
+
page: zod.default.coerce.number({ error: "page must be a number" }).int({ error: "page must be an integer" }).min(1, { error: "page cannot be less than 1" }).optional(),
|
|
1833
|
+
page_size: zod.default.coerce.number({ error: "page_size must be a number" }).int({ error: "page_size must be an integer" }).min(1, { error: "page_size cannot be less than 1" }).max(100, { error: "page_size cannot be greater than 100" }).optional(),
|
|
1834
|
+
sort: zod.default.enum(SearchSortTypeValues, { error: "Invalid sort type" }).optional(),
|
|
1835
|
+
note_type: zod.default.coerce.number({ error: "note_type must be a number" }).int({ error: "note_type must be an integer" }).refine((val) => SearchNoteTypeValues.includes(val), { message: "Invalid note type" }).optional()
|
|
1836
|
+
})
|
|
1613
1837
|
};
|
|
1614
1838
|
/**
|
|
1615
1839
|
* 小红书方法路由映射
|
|
@@ -1623,7 +1847,6 @@ const XiaohongshuMethodRoutes = {
|
|
|
1623
1847
|
emojiList: "/fetch_emoji_list",
|
|
1624
1848
|
searchNotes: "/fetch_search_notes"
|
|
1625
1849
|
};
|
|
1626
|
-
|
|
1627
1850
|
//#endregion
|
|
1628
1851
|
//#region src/validation/index.ts
|
|
1629
1852
|
/**
|
|
@@ -1693,10 +1916,10 @@ const validateXiaohongshuParams = (methodType, params) => {
|
|
|
1693
1916
|
* @param code - 响应状态码(可选,默认200)
|
|
1694
1917
|
* @returns 格式化的成功API响应对象
|
|
1695
1918
|
*/
|
|
1696
|
-
const createSuccessResponse = (data
|
|
1919
|
+
const createSuccessResponse = (data, message, code = 200) => {
|
|
1697
1920
|
return {
|
|
1698
1921
|
success: true,
|
|
1699
|
-
data
|
|
1922
|
+
data,
|
|
1700
1923
|
message,
|
|
1701
1924
|
code,
|
|
1702
1925
|
error: void 0
|
|
@@ -1709,16 +1932,15 @@ const createSuccessResponse = (data$1, message, code = 200) => {
|
|
|
1709
1932
|
* @param code - 错误状态码(可选,默认500)
|
|
1710
1933
|
* @returns 格式化的错误响应对象
|
|
1711
1934
|
*/
|
|
1712
|
-
const createErrorResponse = (error, message, code = 500, data
|
|
1935
|
+
const createErrorResponse = (error, message, code = 500, data) => {
|
|
1713
1936
|
return {
|
|
1714
1937
|
success: false,
|
|
1715
1938
|
error,
|
|
1716
1939
|
message,
|
|
1717
1940
|
code,
|
|
1718
|
-
data
|
|
1941
|
+
data
|
|
1719
1942
|
};
|
|
1720
1943
|
};
|
|
1721
|
-
|
|
1722
1944
|
//#endregion
|
|
1723
1945
|
//#region src/model/fetchers/bilibili/internal.ts
|
|
1724
1946
|
/**
|
|
@@ -1739,15 +1961,20 @@ async function fetchBilibiliInternal(methodType, options, config) {
|
|
|
1739
1961
|
const rawData = await fetchBilibili({ ...validateBilibiliParams(methodType, options) }, config.cookie, config.requestConfig);
|
|
1740
1962
|
const duration = Date.now() - startTime;
|
|
1741
1963
|
if (rawData.code !== 0) {
|
|
1964
|
+
const errorMessage = rawData.message || "B站数据获取失败";
|
|
1742
1965
|
emitApiError({
|
|
1743
1966
|
platform: "bilibili",
|
|
1744
1967
|
methodType,
|
|
1745
1968
|
errorCode: rawData.code,
|
|
1746
|
-
errorMessage
|
|
1969
|
+
errorMessage,
|
|
1747
1970
|
url: void 0,
|
|
1748
1971
|
duration
|
|
1749
1972
|
});
|
|
1750
|
-
return createErrorResponse(rawData.amagiError
|
|
1973
|
+
return createErrorResponse(rawData.amagiError ?? {
|
|
1974
|
+
errorDescription: errorMessage,
|
|
1975
|
+
requestType: methodType,
|
|
1976
|
+
requestUrl: void 0
|
|
1977
|
+
}, errorMessage, rawData.code, rawData);
|
|
1751
1978
|
}
|
|
1752
1979
|
const result = createSuccessResponse(rawData, "获取成功", 200);
|
|
1753
1980
|
emitApiSuccess({
|
|
@@ -1770,7 +1997,6 @@ async function fetchBilibiliInternal(methodType, options, config) {
|
|
|
1770
1997
|
throw new Error(`B站数据获取失败: ${errorMessage}`);
|
|
1771
1998
|
}
|
|
1772
1999
|
}
|
|
1773
|
-
|
|
1774
2000
|
//#endregion
|
|
1775
2001
|
//#region src/model/fetchers/bilibili/article.ts
|
|
1776
2002
|
/**
|
|
@@ -1849,7 +2075,6 @@ async function fetchArticleListInfo(options, cookie, requestConfig) {
|
|
|
1849
2075
|
requestConfig
|
|
1850
2076
|
});
|
|
1851
2077
|
}
|
|
1852
|
-
|
|
1853
2078
|
//#endregion
|
|
1854
2079
|
//#region src/model/fetchers/bilibili/auth.ts
|
|
1855
2080
|
/**
|
|
@@ -1950,7 +2175,6 @@ async function validateCaptchaResult(options, cookie, requestConfig) {
|
|
|
1950
2175
|
requestConfig
|
|
1951
2176
|
});
|
|
1952
2177
|
}
|
|
1953
|
-
|
|
1954
2178
|
//#endregion
|
|
1955
2179
|
//#region src/model/fetchers/bilibili/bangumi.ts
|
|
1956
2180
|
/**
|
|
@@ -1993,7 +2217,6 @@ async function fetchBangumiStreamUrl(options, cookie, requestConfig) {
|
|
|
1993
2217
|
requestConfig
|
|
1994
2218
|
});
|
|
1995
2219
|
}
|
|
1996
|
-
|
|
1997
2220
|
//#endregion
|
|
1998
2221
|
//#region src/model/fetchers/bilibili/comment.ts
|
|
1999
2222
|
/**
|
|
@@ -2037,7 +2260,6 @@ async function fetchCommentReplies$1(options, cookie, requestConfig) {
|
|
|
2037
2260
|
requestConfig
|
|
2038
2261
|
});
|
|
2039
2262
|
}
|
|
2040
|
-
|
|
2041
2263
|
//#endregion
|
|
2042
2264
|
//#region src/model/fetchers/bilibili/dynamic.ts
|
|
2043
2265
|
/**
|
|
@@ -2061,24 +2283,29 @@ async function fetchDynamicDetail(options, cookie, requestConfig) {
|
|
|
2061
2283
|
}
|
|
2062
2284
|
/**
|
|
2063
2285
|
* 获取B站动态卡片信息
|
|
2286
|
+
*
|
|
2287
|
+
* @deprecated v6.1.3 已废弃,B站官方已于 `2025-08-09` 删除原 `dynamic_svr` 接口。
|
|
2288
|
+
* 调用将返回错误信息
|
|
2289
|
+
* 计划于 v7.0.0 移除。
|
|
2290
|
+
*
|
|
2064
2291
|
* @param options - 动态参数
|
|
2065
2292
|
* @param options.dynamic_id - 动态 ID
|
|
2066
2293
|
* @param cookie - B站 Cookie (可选)
|
|
2067
2294
|
* @param requestConfig - 请求配置 (可选)
|
|
2068
|
-
* @returns
|
|
2295
|
+
* @returns 动态卡片数据(已停用,返回错误信息)
|
|
2069
2296
|
* @example
|
|
2070
2297
|
* ```typescript
|
|
2071
2298
|
* const result = await fetchDynamicCard({ dynamic_id: '123456789' }, cookie)
|
|
2072
|
-
*
|
|
2299
|
+
* // result.success === false,错误信息提示接口已停用
|
|
2073
2300
|
* ```
|
|
2074
2301
|
*/
|
|
2075
2302
|
async function fetchDynamicCard(options, cookie, requestConfig) {
|
|
2303
|
+
checkDeprecation("fetchDynamicCard");
|
|
2076
2304
|
return fetchBilibiliInternal("dynamicCard", options, {
|
|
2077
2305
|
cookie,
|
|
2078
2306
|
requestConfig
|
|
2079
2307
|
});
|
|
2080
2308
|
}
|
|
2081
|
-
|
|
2082
2309
|
//#endregion
|
|
2083
2310
|
//#region src/model/fetchers/bilibili/live.ts
|
|
2084
2311
|
/**
|
|
@@ -2119,7 +2346,6 @@ async function fetchLiveRoomInitInfo(options, cookie, requestConfig) {
|
|
|
2119
2346
|
requestConfig
|
|
2120
2347
|
});
|
|
2121
2348
|
}
|
|
2122
|
-
|
|
2123
2349
|
//#endregion
|
|
2124
2350
|
//#region src/model/fetchers/bilibili/user.ts
|
|
2125
2351
|
/**
|
|
@@ -2198,7 +2424,6 @@ async function fetchUploaderTotalViews(options, cookie, requestConfig) {
|
|
|
2198
2424
|
requestConfig
|
|
2199
2425
|
});
|
|
2200
2426
|
}
|
|
2201
|
-
|
|
2202
2427
|
//#endregion
|
|
2203
2428
|
//#region src/model/fetchers/bilibili/utils.ts
|
|
2204
2429
|
/**
|
|
@@ -2258,7 +2483,6 @@ async function fetchEmojiList$3(options, cookie, requestConfig) {
|
|
|
2258
2483
|
requestConfig
|
|
2259
2484
|
});
|
|
2260
2485
|
}
|
|
2261
|
-
|
|
2262
2486
|
//#endregion
|
|
2263
2487
|
//#region src/model/fetchers/bilibili/video.ts
|
|
2264
2488
|
/**
|
|
@@ -2319,7 +2543,6 @@ async function fetchVideoDanmaku(options, cookie, requestConfig) {
|
|
|
2319
2543
|
requestConfig
|
|
2320
2544
|
});
|
|
2321
2545
|
}
|
|
2322
|
-
|
|
2323
2546
|
//#endregion
|
|
2324
2547
|
//#region src/model/fetchers/bilibili/bound.ts
|
|
2325
2548
|
/**
|
|
@@ -2347,6 +2570,7 @@ function createBoundBilibiliFetcher(cookie, requestConfig) {
|
|
|
2347
2570
|
fetchUserSpaceInfo: (options) => fetchUserSpaceInfo(options, cookie, requestConfig),
|
|
2348
2571
|
fetchUploaderTotalViews: (options) => fetchUploaderTotalViews(options, cookie, requestConfig),
|
|
2349
2572
|
fetchDynamicDetail: (options) => fetchDynamicDetail(options, cookie, requestConfig),
|
|
2573
|
+
/** @deprecated v6.1.3 已废弃,调用将返回错误信息 */
|
|
2350
2574
|
fetchDynamicCard: (options) => fetchDynamicCard(options, cookie, requestConfig),
|
|
2351
2575
|
fetchBangumiInfo: (options) => fetchBangumiInfo(options, cookie, requestConfig),
|
|
2352
2576
|
fetchBangumiStreamUrl: (options) => fetchBangumiStreamUrl(options, cookie, requestConfig),
|
|
@@ -2366,7 +2590,6 @@ function createBoundBilibiliFetcher(cookie, requestConfig) {
|
|
|
2366
2590
|
fetchEmojiList: (options) => fetchEmojiList$3(options, cookie, requestConfig)
|
|
2367
2591
|
};
|
|
2368
2592
|
}
|
|
2369
|
-
|
|
2370
2593
|
//#endregion
|
|
2371
2594
|
//#region src/model/fetchers/bilibili/index.ts
|
|
2372
2595
|
/**
|
|
@@ -2412,7 +2635,6 @@ const bilibiliFetcher = {
|
|
|
2412
2635
|
convertBvToAv,
|
|
2413
2636
|
fetchEmojiList: fetchEmojiList$3
|
|
2414
2637
|
};
|
|
2415
|
-
|
|
2416
2638
|
//#endregion
|
|
2417
2639
|
//#region src/platform/defaultConfigs.ts
|
|
2418
2640
|
/**
|
|
@@ -2433,7 +2655,7 @@ const generateSecChUa = (userAgent) => {
|
|
|
2433
2655
|
*/
|
|
2434
2656
|
const getDouyinDefaultConfig = (cookie, requestConfig) => {
|
|
2435
2657
|
let finalUserAgent = requestConfig?.headers?.["User-Agent"] ?? "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36";
|
|
2436
|
-
finalUserAgent = finalUserAgent.replace(/\s+Edg\/[\d
|
|
2658
|
+
finalUserAgent = finalUserAgent.replace(/\s+Edg\/[\d.]+/g, "");
|
|
2437
2659
|
const defHeaders = {
|
|
2438
2660
|
Accept: "application/json, text/plain, */*",
|
|
2439
2661
|
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
@@ -2547,158 +2769,34 @@ const getXiaohongshuDefaultConfig = (cookie) => {
|
|
|
2547
2769
|
cookie: cookie ?? ""
|
|
2548
2770
|
} };
|
|
2549
2771
|
};
|
|
2550
|
-
|
|
2551
2772
|
//#endregion
|
|
2552
2773
|
//#region src/types/NetworksConfigType.ts
|
|
2553
|
-
/** 未知错误 */
|
|
2554
|
-
let amagiAPIErrorCode = /* @__PURE__ */ function(amagiAPIErrorCode$1) {
|
|
2555
|
-
/** 未知错误 */
|
|
2556
|
-
amagiAPIErrorCode$1["UNKNOWN"] = "UNKNOWN_ERROR";
|
|
2557
|
-
return amagiAPIErrorCode$1;
|
|
2558
|
-
}({});
|
|
2559
|
-
/** 抖音平台API错误码 */
|
|
2560
|
-
let douoyinAPIErrorCode = /* @__PURE__ */ function(douoyinAPIErrorCode$1) {
|
|
2561
|
-
/** Cookie无效或已过期 */
|
|
2562
|
-
douoyinAPIErrorCode$1["COOKIE"] = "INVALID_COOKIE";
|
|
2563
|
-
/** 内容被隐藏或下架 */
|
|
2564
|
-
douoyinAPIErrorCode$1["FILTER"] = "CONTENT_FILTERED";
|
|
2565
|
-
/** 当前用户未开播 */
|
|
2566
|
-
douoyinAPIErrorCode$1["NOT_LIVE"] = "USER_NOT_LIVE";
|
|
2567
|
-
/** 未知错误 */
|
|
2568
|
-
douoyinAPIErrorCode$1["UNKNOWN"] = "UNKNOWN_ERROR";
|
|
2569
|
-
return douoyinAPIErrorCode$1;
|
|
2570
|
-
}({});
|
|
2571
|
-
/** B站平台API错误码 */
|
|
2572
|
-
let bilibiliAPIErrorCode = /* @__PURE__ */ function(bilibiliAPIErrorCode$1) {
|
|
2573
|
-
/** 应用程序不存在或已被封禁 */
|
|
2574
|
-
bilibiliAPIErrorCode$1["APP_NOT_FOUND"] = "-1";
|
|
2575
|
-
/** Access Key 错误 */
|
|
2576
|
-
bilibiliAPIErrorCode$1["ACCESS_KEY_ERROR"] = "-2";
|
|
2577
|
-
/** API 校验密匙错误 */
|
|
2578
|
-
bilibiliAPIErrorCode$1["API_KEY_ERROR"] = "-3";
|
|
2579
|
-
/** 调用方对该Method没有权限 */
|
|
2580
|
-
bilibiliAPIErrorCode$1["METHOD_NOT_PERMITTED"] = "-4";
|
|
2581
|
-
/** 账号未登录 */
|
|
2582
|
-
bilibiliAPIErrorCode$1["NOT_LOGGED_IN"] = "-101";
|
|
2583
|
-
/** 账号被封停 */
|
|
2584
|
-
bilibiliAPIErrorCode$1["ACCOUNT_BANNED"] = "-102";
|
|
2585
|
-
/** 积分不足 */
|
|
2586
|
-
bilibiliAPIErrorCode$1["POINTS_INSUFFICIENT"] = "-103";
|
|
2587
|
-
/** 硬币不足 */
|
|
2588
|
-
bilibiliAPIErrorCode$1["COINS_INSUFFICIENT"] = "-104";
|
|
2589
|
-
/** 验证码错误 */
|
|
2590
|
-
bilibiliAPIErrorCode$1["CAPTCHA_ERROR"] = "-105";
|
|
2591
|
-
/** 账号非正式会员或在适应期 */
|
|
2592
|
-
bilibiliAPIErrorCode$1["MEMBERSHIP_LIMITED"] = "-106";
|
|
2593
|
-
/** 应用不存在或者被封禁 */
|
|
2594
|
-
bilibiliAPIErrorCode$1["APP_BANNED"] = "-107";
|
|
2595
|
-
/** 未绑定手机 */
|
|
2596
|
-
bilibiliAPIErrorCode$1["PHONE_NOT_BOUND"] = "-108";
|
|
2597
|
-
/** 未绑定手机 */
|
|
2598
|
-
bilibiliAPIErrorCode$1["PHONE_NOT_BOUND_2"] = "-110";
|
|
2599
|
-
/** csrf 校验失败 */
|
|
2600
|
-
bilibiliAPIErrorCode$1["CSRF_ERROR"] = "-111";
|
|
2601
|
-
/** 系统升级中 */
|
|
2602
|
-
bilibiliAPIErrorCode$1["SYSTEM_UPDATING"] = "-112";
|
|
2603
|
-
/** 账号尚未实名认证 */
|
|
2604
|
-
bilibiliAPIErrorCode$1["NOT_REAL_NAME_VERIFIED"] = "-113";
|
|
2605
|
-
/** 请先绑定手机 */
|
|
2606
|
-
bilibiliAPIErrorCode$1["NEED_BIND_PHONE"] = "-114";
|
|
2607
|
-
/** 请先完成实名认证 */
|
|
2608
|
-
bilibiliAPIErrorCode$1["NEED_REAL_NAME_VERIFICATION"] = "-115";
|
|
2609
|
-
/** 木有改动 */
|
|
2610
|
-
bilibiliAPIErrorCode$1["NO_CHANGE"] = "-304";
|
|
2611
|
-
/** 撞车跳转 */
|
|
2612
|
-
bilibiliAPIErrorCode$1["CONFLICT_REDIRECT"] = "-307";
|
|
2613
|
-
/** 风控校验失败 (UA 或 wbi 参数不合法) */
|
|
2614
|
-
bilibiliAPIErrorCode$1["RISK_CONTROL_FAILED"] = "-352";
|
|
2615
|
-
/** 请求错误 */
|
|
2616
|
-
bilibiliAPIErrorCode$1["BAD_REQUEST"] = "-400";
|
|
2617
|
-
/** 未认证 (或非法请求) */
|
|
2618
|
-
bilibiliAPIErrorCode$1["UNAUTHORIZED"] = "-401";
|
|
2619
|
-
/** 访问权限不足 */
|
|
2620
|
-
bilibiliAPIErrorCode$1["FORBIDDEN"] = "-403";
|
|
2621
|
-
/** 啥都木有 */
|
|
2622
|
-
bilibiliAPIErrorCode$1["NOT_FOUND"] = "-404";
|
|
2623
|
-
/** 不支持该方法 */
|
|
2624
|
-
bilibiliAPIErrorCode$1["METHOD_NOT_ALLOWED"] = "-405";
|
|
2625
|
-
/** 冲突 */
|
|
2626
|
-
bilibiliAPIErrorCode$1["CONFLICT"] = "-409";
|
|
2627
|
-
/** 请求被拦截 (客户端 ip 被服务端风控) */
|
|
2628
|
-
bilibiliAPIErrorCode$1["IP_BLOCKED"] = "-412";
|
|
2629
|
-
/** 服务器错误 */
|
|
2630
|
-
bilibiliAPIErrorCode$1["SERVER_ERROR"] = "-500";
|
|
2631
|
-
/** 过载保护,服务暂不可用 */
|
|
2632
|
-
bilibiliAPIErrorCode$1["SERVICE_UNAVAILABLE"] = "-503";
|
|
2633
|
-
/** 服务调用超时 */
|
|
2634
|
-
bilibiliAPIErrorCode$1["GATEWAY_TIMEOUT"] = "-504";
|
|
2635
|
-
/** 超出限制 */
|
|
2636
|
-
bilibiliAPIErrorCode$1["RATE_LIMITED"] = "-509";
|
|
2637
|
-
/** 上传文件不存在 */
|
|
2638
|
-
bilibiliAPIErrorCode$1["FILE_NOT_FOUND"] = "-616";
|
|
2639
|
-
/** 上传文件太大 */
|
|
2640
|
-
bilibiliAPIErrorCode$1["FILE_TOO_LARGE"] = "-617";
|
|
2641
|
-
/** 登录失败次数太多 */
|
|
2642
|
-
bilibiliAPIErrorCode$1["LOGIN_ATTEMPTS_EXCEEDED"] = "-625";
|
|
2643
|
-
/** 用户不存在 */
|
|
2644
|
-
bilibiliAPIErrorCode$1["USER_NOT_FOUND"] = "-626";
|
|
2645
|
-
/** 密码太弱 */
|
|
2646
|
-
bilibiliAPIErrorCode$1["WEAK_PASSWORD"] = "-628";
|
|
2647
|
-
/** 用户名或密码错误 */
|
|
2648
|
-
bilibiliAPIErrorCode$1["INVALID_CREDENTIALS"] = "-629";
|
|
2649
|
-
/** 操作对象数量限制 */
|
|
2650
|
-
bilibiliAPIErrorCode$1["OBJECT_LIMIT_EXCEEDED"] = "-632";
|
|
2651
|
-
/** 被锁定 */
|
|
2652
|
-
bilibiliAPIErrorCode$1["ACCOUNT_LOCKED"] = "-643";
|
|
2653
|
-
/** 用户等级太低 */
|
|
2654
|
-
bilibiliAPIErrorCode$1["USER_LEVEL_TOO_LOW"] = "-650";
|
|
2655
|
-
/** 重复的用户 */
|
|
2656
|
-
bilibiliAPIErrorCode$1["DUPLICATE_USER"] = "-652";
|
|
2657
|
-
/** Token 过期 */
|
|
2658
|
-
bilibiliAPIErrorCode$1["TOKEN_EXPIRED"] = "-658";
|
|
2659
|
-
/** 密码时间戳过期 */
|
|
2660
|
-
bilibiliAPIErrorCode$1["PASSWORD_TIMESTAMP_EXPIRED"] = "-662";
|
|
2661
|
-
/** 地理区域限制 */
|
|
2662
|
-
bilibiliAPIErrorCode$1["GEO_RESTRICTED"] = "-688";
|
|
2663
|
-
/** 版权限制 */
|
|
2664
|
-
bilibiliAPIErrorCode$1["COPYRIGHT_RESTRICTED"] = "-689";
|
|
2665
|
-
/** 扣节操失败 */
|
|
2666
|
-
bilibiliAPIErrorCode$1["REPUTATION_DEDUCTION_FAILED"] = "-701";
|
|
2667
|
-
/** 请求过于频繁,请稍后再试 */
|
|
2668
|
-
bilibiliAPIErrorCode$1["TOO_MANY_REQUESTS"] = "-799";
|
|
2669
|
-
/** 服务器开小差了 */
|
|
2670
|
-
bilibiliAPIErrorCode$1["SERVER_TEMPORARILY_UNAVAILABLE"] = "-8888";
|
|
2671
|
-
/** 未知错误 */
|
|
2672
|
-
bilibiliAPIErrorCode$1["UNKNOWN"] = "UNKNOWN";
|
|
2673
|
-
return bilibiliAPIErrorCode$1;
|
|
2674
|
-
}({});
|
|
2675
2774
|
/** 快手平台API错误码 */
|
|
2676
|
-
let kuaishouAPIErrorCode = /* @__PURE__ */ function(kuaishouAPIErrorCode
|
|
2775
|
+
let kuaishouAPIErrorCode = /* @__PURE__ */ function(kuaishouAPIErrorCode) {
|
|
2677
2776
|
/** Cookie无效或已过期 */
|
|
2678
|
-
kuaishouAPIErrorCode
|
|
2777
|
+
kuaishouAPIErrorCode["COOKIE"] = "INVALID_COOKIE";
|
|
2679
2778
|
/** 未知错误 */
|
|
2680
|
-
kuaishouAPIErrorCode
|
|
2681
|
-
return kuaishouAPIErrorCode
|
|
2779
|
+
kuaishouAPIErrorCode["UNKNOWN"] = "UNKNOWN_ERROR";
|
|
2780
|
+
return kuaishouAPIErrorCode;
|
|
2682
2781
|
}({});
|
|
2683
2782
|
/** 小红书平台API错误码 */
|
|
2684
|
-
let xiaohongshuAPIErrorCode = /* @__PURE__ */ function(xiaohongshuAPIErrorCode
|
|
2783
|
+
let xiaohongshuAPIErrorCode = /* @__PURE__ */ function(xiaohongshuAPIErrorCode) {
|
|
2685
2784
|
/** Cookie无效或已过期 */
|
|
2686
|
-
xiaohongshuAPIErrorCode
|
|
2785
|
+
xiaohongshuAPIErrorCode["COOKIE"] = "INVALID_COOKIE";
|
|
2687
2786
|
/** 未知错误 */
|
|
2688
|
-
xiaohongshuAPIErrorCode
|
|
2787
|
+
xiaohongshuAPIErrorCode["UNKNOWN"] = "UNKNOWN_ERROR";
|
|
2689
2788
|
/** 非法请求 */
|
|
2690
|
-
xiaohongshuAPIErrorCode
|
|
2789
|
+
xiaohongshuAPIErrorCode[xiaohongshuAPIErrorCode["ILLEGAL_REQUEST"] = 500] = "ILLEGAL_REQUEST";
|
|
2691
2790
|
/** 检测到帐号异常,请稍后重试 */
|
|
2692
|
-
xiaohongshuAPIErrorCode
|
|
2791
|
+
xiaohongshuAPIErrorCode[xiaohongshuAPIErrorCode["ACCOUNT_ABNORMAL"] = 300011] = "ACCOUNT_ABNORMAL";
|
|
2693
2792
|
/** 网络连接异常,请检查网络设置后重试 */
|
|
2694
|
-
xiaohongshuAPIErrorCode
|
|
2793
|
+
xiaohongshuAPIErrorCode[xiaohongshuAPIErrorCode["NETWORK_ERROR"] = 300012] = "NETWORK_ERROR";
|
|
2695
2794
|
/** 访问频次异常,请勿频繁操作 */
|
|
2696
|
-
xiaohongshuAPIErrorCode
|
|
2795
|
+
xiaohongshuAPIErrorCode[xiaohongshuAPIErrorCode["FREQUENCY_ERROR"] = 300013] = "FREQUENCY_ERROR";
|
|
2697
2796
|
/** 浏览器异常,请尝试更换浏览器后重试 */
|
|
2698
|
-
xiaohongshuAPIErrorCode
|
|
2699
|
-
return xiaohongshuAPIErrorCode
|
|
2797
|
+
xiaohongshuAPIErrorCode[xiaohongshuAPIErrorCode["BROWSER_ERROR"] = 300015] = "BROWSER_ERROR";
|
|
2798
|
+
return xiaohongshuAPIErrorCode;
|
|
2700
2799
|
}({});
|
|
2701
|
-
|
|
2702
2800
|
//#endregion
|
|
2703
2801
|
//#region src/platform/douyin/sign/a_bogus.ts
|
|
2704
2802
|
var SM3 = class {
|
|
@@ -2732,7 +2830,8 @@ var SM3 = class {
|
|
|
2732
2830
|
this.chunk = this.chunk.concat(a.slice(0, f));
|
|
2733
2831
|
while (this.chunk.length >= 64) {
|
|
2734
2832
|
this._compress(this.chunk);
|
|
2735
|
-
f < a.length
|
|
2833
|
+
if (f < a.length) this.chunk = a.slice(f, Math.min(f + 64, a.length));
|
|
2834
|
+
else this.chunk = [];
|
|
2736
2835
|
f += 64;
|
|
2737
2836
|
}
|
|
2738
2837
|
}
|
|
@@ -2768,10 +2867,17 @@ var SM3 = class {
|
|
|
2768
2867
|
if (t.length < 64) console.error("compress error: not enough data");
|
|
2769
2868
|
else {
|
|
2770
2869
|
for (var f = ((e) => {
|
|
2771
|
-
for (var r = new Array(132), t
|
|
2870
|
+
for (var r = new Array(132), t = 0; t < 16; t++) {
|
|
2871
|
+
r[t] = e[4 * t] << 24;
|
|
2872
|
+
r[t] |= e[4 * t + 1] << 16;
|
|
2873
|
+
r[t] |= e[4 * t + 2] << 8;
|
|
2874
|
+
r[t] |= e[4 * t + 3];
|
|
2875
|
+
r[t] >>>= 0;
|
|
2876
|
+
}
|
|
2772
2877
|
for (var n = 16; n < 68; n++) {
|
|
2773
2878
|
let a = r[n - 16] ^ r[n - 9] ^ this.le(r[n - 3], 15);
|
|
2774
|
-
a = a ^ this.le(a, 15) ^ this.le(a, 23)
|
|
2879
|
+
a = a ^ this.le(a, 15) ^ this.le(a, 23);
|
|
2880
|
+
r[n] = (a ^ this.le(r[n - 13], 7) ^ r[n - 6]) >>> 0;
|
|
2775
2881
|
}
|
|
2776
2882
|
for (n = 0; n < 64; n++) r[n + 68] = (r[n] ^ r[n + 4]) >>> 0;
|
|
2777
2883
|
return r;
|
|
@@ -2781,7 +2887,15 @@ var SM3 = class {
|
|
|
2781
2887
|
let u = this.pe(c, i[0], i[1], i[2]);
|
|
2782
2888
|
u = (4294967295 & (u = u + i[3] + s + f[c + 68])) >>> 0;
|
|
2783
2889
|
let b = this.he(c, i[4], i[5], i[6]);
|
|
2784
|
-
b = (4294967295 & (b = b + i[7] + o + f[c])) >>> 0
|
|
2890
|
+
b = (4294967295 & (b = b + i[7] + o + f[c])) >>> 0;
|
|
2891
|
+
i[3] = i[2];
|
|
2892
|
+
i[2] = this.le(i[1], 9);
|
|
2893
|
+
i[1] = i[0];
|
|
2894
|
+
i[0] = u;
|
|
2895
|
+
i[7] = i[6];
|
|
2896
|
+
i[6] = this.le(i[5], 19);
|
|
2897
|
+
i[5] = i[4];
|
|
2898
|
+
i[4] = (b ^ this.le(b, 9) ^ this.le(b, 17)) >>> 0;
|
|
2785
2899
|
}
|
|
2786
2900
|
for (let l = 0; l < 8; l++) this.reg[l] = (this.reg[l] ^ i[l]) >>> 0;
|
|
2787
2901
|
}
|
|
@@ -2847,18 +2961,17 @@ function rc4_encrypt(plaintext, key) {
|
|
|
2847
2961
|
return cipher.join("");
|
|
2848
2962
|
}
|
|
2849
2963
|
function result_encrypt(long_str, num) {
|
|
2850
|
-
const s_obj = {
|
|
2851
|
-
s0: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
|
2852
|
-
s1: "Dkdpgh4ZKsQB80/Mfvw36XI1R25+WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=",
|
|
2853
|
-
s2: "Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=",
|
|
2854
|
-
s3: "ckdp1h4ZKsUB80/Mfvw36XIgR25+WQAlEi7NLboqYTOPuzmFjJnryx9HVGDaStCe",
|
|
2855
|
-
s4: "Dkdpgh2ZmsQB80/MfvV36XI1R45-WUAlEixNLwoqYTOPuzKFjJnry79HbGcaStCe"
|
|
2856
|
-
};
|
|
2857
2964
|
const constant = {
|
|
2858
2965
|
0: 16515072,
|
|
2859
2966
|
1: 258048,
|
|
2860
2967
|
2: 4032,
|
|
2861
|
-
str:
|
|
2968
|
+
str: {
|
|
2969
|
+
s0: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
|
2970
|
+
s1: "Dkdpgh4ZKsQB80/Mfvw36XI1R25+WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=",
|
|
2971
|
+
s2: "Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=",
|
|
2972
|
+
s3: "ckdp1h4ZKsUB80/Mfvw36XIgR25+WQAlEi7NLboqYTOPuzmFjJnryx9HVGDaStCe",
|
|
2973
|
+
s4: "Dkdpgh2ZmsQB80/MfvV36XI1R45-WUAlEixNLwoqYTOPuzKFjJnry79HbGcaStCe"
|
|
2974
|
+
}[num]
|
|
2862
2975
|
};
|
|
2863
2976
|
let result = "";
|
|
2864
2977
|
let lound = 0;
|
|
@@ -2918,10 +3031,9 @@ function generate_rc4_bb_str(url_search_params, user_agent, window_env_str, suff
|
|
|
2918
3031
|
1,
|
|
2919
3032
|
14
|
|
2920
3033
|
])), "s3"));
|
|
2921
|
-
const end_time = Date.now();
|
|
2922
3034
|
let b = {
|
|
2923
3035
|
8: 3,
|
|
2924
|
-
10:
|
|
3036
|
+
10: Date.now(),
|
|
2925
3037
|
15: {
|
|
2926
3038
|
aid: 6383,
|
|
2927
3039
|
pageId: 6241,
|
|
@@ -3094,7 +3206,7 @@ function generate_random_str() {
|
|
|
3094
3206
|
* @returns 清理后的User-Agent字符串
|
|
3095
3207
|
*/
|
|
3096
3208
|
const cleanUserAgentForSigning = (userAgent) => {
|
|
3097
|
-
return userAgent.replace(/\s+Edg\/[\d
|
|
3209
|
+
return userAgent.replace(/\s+Edg\/[\d.]+/g, "");
|
|
3098
3210
|
};
|
|
3099
3211
|
/**
|
|
3100
3212
|
* 抖音a_bogus签名算法
|
|
@@ -3106,7 +3218,6 @@ var a_bogus_default = (url, user_agent) => {
|
|
|
3106
3218
|
const cleanedUserAgent = cleanUserAgentForSigning(user_agent);
|
|
3107
3219
|
return result_encrypt(generate_random_str() + generate_rc4_bb_str(new URLSearchParams(new URL(url).search).toString(), cleanedUserAgent, "1536|747|1536|834|0|30|0|0|1536|834|1536|864|1525|747|24|24|Win32"), "s4") + "=";
|
|
3108
3220
|
};
|
|
3109
|
-
|
|
3110
3221
|
//#endregion
|
|
3111
3222
|
//#region src/platform/douyin/sign/x_bogus.ts
|
|
3112
3223
|
/**
|
|
@@ -3171,14 +3282,14 @@ var XBogus = class {
|
|
|
3171
3282
|
encodingConversion2(a, b, c) {
|
|
3172
3283
|
return String.fromCharCode(a) + String.fromCharCode(b) + c;
|
|
3173
3284
|
}
|
|
3174
|
-
rc4Encrypt(key, data
|
|
3285
|
+
rc4Encrypt(key, data) {
|
|
3175
3286
|
const keyBuffer = typeof key === "string" ? Buffer.from(key, "latin1") : key;
|
|
3176
|
-
const dataBuffer = Buffer.from(data
|
|
3177
|
-
const S = Array.from({ length: 256 }, (_, i
|
|
3287
|
+
const dataBuffer = Buffer.from(data, "latin1");
|
|
3288
|
+
const S = Array.from({ length: 256 }, (_, i) => i);
|
|
3178
3289
|
let j = 0;
|
|
3179
|
-
for (let i
|
|
3180
|
-
j = (j + S[i
|
|
3181
|
-
[S[i
|
|
3290
|
+
for (let i = 0; i < 256; i++) {
|
|
3291
|
+
j = (j + S[i] + keyBuffer[i % keyBuffer.length]) % 256;
|
|
3292
|
+
[S[i], S[j]] = [S[j], S[i]];
|
|
3182
3293
|
}
|
|
3183
3294
|
const encryptedBuffer = Buffer.alloc(dataBuffer.length);
|
|
3184
3295
|
let i = 0;
|
|
@@ -3217,7 +3328,6 @@ var XBogus = class {
|
|
|
3217
3328
|
const array2 = this.md5StrToArray(this.md5(this.md5StrToArray("d41d8cd98f00b204e9800998ecf8427e")));
|
|
3218
3329
|
const urlEncryptedArray = this.md5Encrypt(urlPath);
|
|
3219
3330
|
const timestamp = Math.floor(Date.now() / 1e3);
|
|
3220
|
-
const ct = 536919696;
|
|
3221
3331
|
const newArray = [
|
|
3222
3332
|
64,
|
|
3223
3333
|
1,
|
|
@@ -3233,10 +3343,10 @@ var XBogus = class {
|
|
|
3233
3343
|
timestamp >> 16 & 255,
|
|
3234
3344
|
timestamp >> 8 & 255,
|
|
3235
3345
|
timestamp & 255,
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3346
|
+
32,
|
|
3347
|
+
0,
|
|
3348
|
+
190,
|
|
3349
|
+
144
|
|
3240
3350
|
];
|
|
3241
3351
|
let xorResult = newArray[0];
|
|
3242
3352
|
for (let i = 1; i < newArray.length; i++) xorResult ^= newArray[i];
|
|
@@ -3270,7 +3380,6 @@ var XBogus = class {
|
|
|
3270
3380
|
};
|
|
3271
3381
|
}
|
|
3272
3382
|
};
|
|
3273
|
-
|
|
3274
3383
|
//#endregion
|
|
3275
3384
|
//#region src/platform/douyin/sign/index.ts
|
|
3276
3385
|
const defaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36";
|
|
@@ -3319,7 +3428,6 @@ var douyinSign = class {
|
|
|
3319
3428
|
return "verify_" + n + "_" + r.join("");
|
|
3320
3429
|
}
|
|
3321
3430
|
};
|
|
3322
|
-
|
|
3323
3431
|
//#endregion
|
|
3324
3432
|
//#region src/platform/douyin/API.ts
|
|
3325
3433
|
/**
|
|
@@ -3393,10 +3501,10 @@ var DouyinAPI = class {
|
|
|
3393
3501
|
};
|
|
3394
3502
|
}
|
|
3395
3503
|
/** 获取视频或图集数据 */
|
|
3396
|
-
getWorkDetail(data
|
|
3504
|
+
getWorkDetail(data) {
|
|
3397
3505
|
return `https://www.douyin.com/aweme/v1/web/aweme/detail/?${buildQueryString({
|
|
3398
3506
|
...this.getBaseParams(),
|
|
3399
|
-
aweme_id: data
|
|
3507
|
+
aweme_id: data.aweme_id,
|
|
3400
3508
|
update_version_code: "170400",
|
|
3401
3509
|
version_code: "190500",
|
|
3402
3510
|
version_name: "19.5.0",
|
|
@@ -3407,12 +3515,12 @@ var DouyinAPI = class {
|
|
|
3407
3515
|
})}`;
|
|
3408
3516
|
}
|
|
3409
3517
|
/** 获取评论数据 */
|
|
3410
|
-
getComments(data
|
|
3518
|
+
getComments(data) {
|
|
3411
3519
|
return `https://www.douyin.com/aweme/v1/web/comment/list/?${buildQueryString({
|
|
3412
3520
|
...this.getBaseParams(),
|
|
3413
|
-
aweme_id: data
|
|
3414
|
-
cursor: data
|
|
3415
|
-
count: data
|
|
3521
|
+
aweme_id: data.aweme_id,
|
|
3522
|
+
cursor: data.cursor ?? 0,
|
|
3523
|
+
count: data.number ?? 50,
|
|
3416
3524
|
item_type: "0",
|
|
3417
3525
|
insert_ids: "",
|
|
3418
3526
|
whale_cut_token: "",
|
|
@@ -3426,16 +3534,16 @@ var DouyinAPI = class {
|
|
|
3426
3534
|
})}`;
|
|
3427
3535
|
}
|
|
3428
3536
|
/** 获取二级评论数据 */
|
|
3429
|
-
getCommentReplies(data
|
|
3537
|
+
getCommentReplies(data) {
|
|
3430
3538
|
return `https://www-hj.douyin.com/aweme/v1/web/comment/list/reply/?${buildQueryString({
|
|
3431
3539
|
device_platform: "webapp",
|
|
3432
3540
|
aid: "6383",
|
|
3433
3541
|
channel: "channel_pc_web",
|
|
3434
|
-
item_id: data
|
|
3435
|
-
comment_id: data
|
|
3542
|
+
item_id: data.aweme_id,
|
|
3543
|
+
comment_id: data.comment_id,
|
|
3436
3544
|
cut_version: "1",
|
|
3437
|
-
cursor: data
|
|
3438
|
-
count: data
|
|
3545
|
+
cursor: data.cursor,
|
|
3546
|
+
count: data.number,
|
|
3439
3547
|
item_type: "0",
|
|
3440
3548
|
update_version_code: "170400",
|
|
3441
3549
|
pc_client_type: "1",
|
|
@@ -3468,12 +3576,12 @@ var DouyinAPI = class {
|
|
|
3468
3576
|
})}`;
|
|
3469
3577
|
}
|
|
3470
3578
|
/** 获取动图数据 */
|
|
3471
|
-
getSlidesInfo(data
|
|
3579
|
+
getSlidesInfo(data) {
|
|
3472
3580
|
return `https://www.iesdouyin.com/web/api/v2/aweme/slidesinfo/?${buildQueryString({
|
|
3473
3581
|
reflow_source: "reflow_page",
|
|
3474
3582
|
web_id: "7326472315356857893",
|
|
3475
3583
|
device_id: "7326472315356857893",
|
|
3476
|
-
aweme_ids: `[${data
|
|
3584
|
+
aweme_ids: `[${data.aweme_id}]`,
|
|
3477
3585
|
request_source: "200",
|
|
3478
3586
|
msToken: douyinSign.Mstoken(116),
|
|
3479
3587
|
verifyFp: fp,
|
|
@@ -3485,18 +3593,18 @@ var DouyinAPI = class {
|
|
|
3485
3593
|
return "https://www.douyin.com/aweme/v1/web/emoji/list";
|
|
3486
3594
|
}
|
|
3487
3595
|
/** 获取用户主页视频数据 */
|
|
3488
|
-
getUserVideoList(data
|
|
3596
|
+
getUserVideoList(data) {
|
|
3489
3597
|
return `https://www.douyin.com/aweme/v1/web/aweme/post/?${buildQueryString({
|
|
3490
3598
|
...this.getBaseParams(),
|
|
3491
|
-
sec_user_id: data
|
|
3492
|
-
max_cursor: data
|
|
3599
|
+
sec_user_id: data.sec_uid,
|
|
3600
|
+
max_cursor: data.max_cursor ?? "0",
|
|
3493
3601
|
locate_query: "false",
|
|
3494
3602
|
show_live_replay_strategy: "1",
|
|
3495
3603
|
need_time_list: "1",
|
|
3496
3604
|
time_list_query: "0",
|
|
3497
3605
|
whale_cut_token: "",
|
|
3498
3606
|
cut_version: "1",
|
|
3499
|
-
count: data
|
|
3607
|
+
count: data.number ?? 18,
|
|
3500
3608
|
publish_video_strategy_type: "2",
|
|
3501
3609
|
version_code: "170400",
|
|
3502
3610
|
version_name: "17.4.0",
|
|
@@ -3507,15 +3615,15 @@ var DouyinAPI = class {
|
|
|
3507
3615
|
})}`;
|
|
3508
3616
|
}
|
|
3509
3617
|
/** 获取用户喜欢列表数据 */
|
|
3510
|
-
getUserFavoriteList(data
|
|
3618
|
+
getUserFavoriteList(data) {
|
|
3511
3619
|
return `https://www-hj.douyin.com/aweme/v1/web/aweme/favorite/?${buildQueryString({
|
|
3512
3620
|
...this.getBaseParams(),
|
|
3513
|
-
sec_user_id: data
|
|
3514
|
-
max_cursor: data
|
|
3621
|
+
sec_user_id: data.sec_uid,
|
|
3622
|
+
max_cursor: data.max_cursor ?? "0",
|
|
3515
3623
|
min_cursor: "0",
|
|
3516
3624
|
whale_cut_token: "",
|
|
3517
3625
|
cut_version: "1",
|
|
3518
|
-
count: data
|
|
3626
|
+
count: data.number ?? 18,
|
|
3519
3627
|
publish_video_strategy_type: "2",
|
|
3520
3628
|
update_version_code: "170400",
|
|
3521
3629
|
pc_libra_divert: "Windows",
|
|
@@ -3530,16 +3638,16 @@ var DouyinAPI = class {
|
|
|
3530
3638
|
})}`;
|
|
3531
3639
|
}
|
|
3532
3640
|
/** 获取用户推荐列表数据 */
|
|
3533
|
-
getUserRecommendList(data
|
|
3641
|
+
getUserRecommendList(data) {
|
|
3534
3642
|
return `https://www.douyin.com/aweme/v1/web/familiar/recommend/feed/?${buildQueryString({
|
|
3535
3643
|
device_platform: "",
|
|
3536
3644
|
aid: "6383",
|
|
3537
3645
|
channel: "channel_pc_web",
|
|
3538
|
-
sec_user_id: data
|
|
3539
|
-
max_cursor: data
|
|
3646
|
+
sec_user_id: data.sec_uid,
|
|
3647
|
+
max_cursor: data.max_cursor ?? "0",
|
|
3540
3648
|
min_cursor: "0",
|
|
3541
3649
|
whale_cut_token: "",
|
|
3542
|
-
count: data
|
|
3650
|
+
count: data.number ?? 18,
|
|
3543
3651
|
from: "1",
|
|
3544
3652
|
update_version_code: "170400",
|
|
3545
3653
|
pc_client_type: "1",
|
|
@@ -3573,12 +3681,12 @@ var DouyinAPI = class {
|
|
|
3573
3681
|
})}`;
|
|
3574
3682
|
}
|
|
3575
3683
|
/** 获取用户主页信息 */
|
|
3576
|
-
getUserProfile(data
|
|
3684
|
+
getUserProfile(data) {
|
|
3577
3685
|
return `https://www.douyin.com/aweme/v1/web/user/profile/other/?${buildQueryString({
|
|
3578
3686
|
...this.getBaseParams(),
|
|
3579
3687
|
publish_video_strategy_type: "2",
|
|
3580
3688
|
source: "channel_pc_web",
|
|
3581
|
-
sec_user_id: data
|
|
3689
|
+
sec_user_id: data.sec_uid,
|
|
3582
3690
|
personal_center_strategy: "1",
|
|
3583
3691
|
version_code: "170400",
|
|
3584
3692
|
version_name: "17.4.0",
|
|
@@ -3589,10 +3697,10 @@ var DouyinAPI = class {
|
|
|
3589
3697
|
})}`;
|
|
3590
3698
|
}
|
|
3591
3699
|
/** 获取热点词数据 */
|
|
3592
|
-
getSuggestWords(data
|
|
3700
|
+
getSuggestWords(data) {
|
|
3593
3701
|
return `https://www.douyin.com/aweme/v1/web/api/suggest_words/?${buildQueryString({
|
|
3594
3702
|
...this.getBaseParams(),
|
|
3595
|
-
query: data
|
|
3703
|
+
query: data.query,
|
|
3596
3704
|
business_id: "30088",
|
|
3597
3705
|
from_group_id: "7129543174929812767",
|
|
3598
3706
|
version_code: "170400",
|
|
@@ -3604,16 +3712,16 @@ var DouyinAPI = class {
|
|
|
3604
3712
|
})}`;
|
|
3605
3713
|
}
|
|
3606
3714
|
/** 获取搜索数据 */
|
|
3607
|
-
search(data
|
|
3608
|
-
const searchType = data
|
|
3609
|
-
const { verifyFp, fp
|
|
3715
|
+
search(data) {
|
|
3716
|
+
const searchType = data.type ?? "general";
|
|
3717
|
+
const { verifyFp, fp, ...baseParamsWithoutFp } = this.getBaseParams();
|
|
3610
3718
|
if (searchType === "user") return `https://www.douyin.com/aweme/v1/web/discover/search/?${buildQueryString({
|
|
3611
3719
|
...baseParamsWithoutFp,
|
|
3612
|
-
count: data
|
|
3720
|
+
count: data.number ?? 10,
|
|
3613
3721
|
disable_rs: "0",
|
|
3614
3722
|
from_group_id: "",
|
|
3615
3723
|
is_filter_search: "0",
|
|
3616
|
-
keyword: data
|
|
3724
|
+
keyword: data.query,
|
|
3617
3725
|
list_type: "single",
|
|
3618
3726
|
need_filter_settings: "1",
|
|
3619
3727
|
offset: "0",
|
|
@@ -3630,16 +3738,16 @@ var DouyinAPI = class {
|
|
|
3630
3738
|
version_code: "170400",
|
|
3631
3739
|
version_name: "17.4.0",
|
|
3632
3740
|
webid: "7521399115230610959",
|
|
3633
|
-
...data
|
|
3741
|
+
...data.search_id && { search_id: data.search_id }
|
|
3634
3742
|
})}`;
|
|
3635
3743
|
else if (searchType === "video") return `https://www.douyin.com/aweme/v1/web/search/item/?${buildQueryString({
|
|
3636
3744
|
...baseParamsWithoutFp,
|
|
3637
|
-
count: data
|
|
3745
|
+
count: data.number ?? 10,
|
|
3638
3746
|
disable_rs: "0",
|
|
3639
3747
|
enable_history: "1",
|
|
3640
3748
|
from_group_id: "",
|
|
3641
3749
|
is_filter_search: "0",
|
|
3642
|
-
keyword: data
|
|
3750
|
+
keyword: data.query,
|
|
3643
3751
|
list_type: "single",
|
|
3644
3752
|
need_filter_settings: "1",
|
|
3645
3753
|
offset: "0",
|
|
@@ -3656,15 +3764,15 @@ var DouyinAPI = class {
|
|
|
3656
3764
|
version_code: "170400",
|
|
3657
3765
|
version_name: "17.4.0",
|
|
3658
3766
|
webid: "7521399115230610959",
|
|
3659
|
-
...data
|
|
3767
|
+
...data.search_id && { search_id: data.search_id }
|
|
3660
3768
|
})}`;
|
|
3661
3769
|
else return `https://www.douyin.com/aweme/v1/web/general/search/stream/?${buildQueryString({
|
|
3662
3770
|
...baseParamsWithoutFp,
|
|
3663
|
-
count: data
|
|
3771
|
+
count: data.number ?? 10,
|
|
3664
3772
|
disable_rs: "0",
|
|
3665
3773
|
enable_history: "1",
|
|
3666
3774
|
is_filter_search: "0",
|
|
3667
|
-
keyword: data
|
|
3775
|
+
keyword: data.query,
|
|
3668
3776
|
list_type: "",
|
|
3669
3777
|
need_filter_settings: "1",
|
|
3670
3778
|
offset: "0",
|
|
@@ -3720,12 +3828,12 @@ var DouyinAPI = class {
|
|
|
3720
3828
|
})}`;
|
|
3721
3829
|
}
|
|
3722
3830
|
/** 获取背景音乐数据 */
|
|
3723
|
-
getMusicInfo(data
|
|
3831
|
+
getMusicInfo(data) {
|
|
3724
3832
|
return `https://www.douyin.com/aweme/v1/web/music/detail/?${buildQueryString({
|
|
3725
3833
|
device_platform: "webapp",
|
|
3726
3834
|
aid: "6383",
|
|
3727
3835
|
channel: "channel_pc_web",
|
|
3728
|
-
music_id: data
|
|
3836
|
+
music_id: data.music_id,
|
|
3729
3837
|
scene: "1",
|
|
3730
3838
|
pc_client_type: "1",
|
|
3731
3839
|
version_code: "170400",
|
|
@@ -3755,7 +3863,7 @@ var DouyinAPI = class {
|
|
|
3755
3863
|
})}`;
|
|
3756
3864
|
}
|
|
3757
3865
|
/** 获取直播间信息 */
|
|
3758
|
-
getLiveRoomInfo(data
|
|
3866
|
+
getLiveRoomInfo(data) {
|
|
3759
3867
|
return `https://live.douyin.com/webcast/room/web/enter/?${buildQueryString({
|
|
3760
3868
|
aid: "6383",
|
|
3761
3869
|
app_name: "douyin_web",
|
|
@@ -3770,8 +3878,8 @@ var DouyinAPI = class {
|
|
|
3770
3878
|
browser_platform: "Win32",
|
|
3771
3879
|
browser_name: "Chrome",
|
|
3772
3880
|
browser_version: "125.0.0.0",
|
|
3773
|
-
web_rid: data
|
|
3774
|
-
room_id_str: data
|
|
3881
|
+
web_rid: data.web_rid,
|
|
3882
|
+
room_id_str: data.room_id,
|
|
3775
3883
|
enter_source: "",
|
|
3776
3884
|
is_need_double_stream: "false",
|
|
3777
3885
|
insert_task_id: "",
|
|
@@ -3782,23 +3890,23 @@ var DouyinAPI = class {
|
|
|
3782
3890
|
})}`;
|
|
3783
3891
|
}
|
|
3784
3892
|
/** 申请登录二维码 */
|
|
3785
|
-
getLoginQrcode(data
|
|
3893
|
+
getLoginQrcode(data) {
|
|
3786
3894
|
return `https://sso.douyin.com/get_qrcode/?${buildQueryString({
|
|
3787
|
-
verifyFp: data
|
|
3788
|
-
fp: data
|
|
3895
|
+
verifyFp: data.verify_fp,
|
|
3896
|
+
fp: data.verify_fp
|
|
3789
3897
|
})}`;
|
|
3790
3898
|
}
|
|
3791
3899
|
/** 获取弹幕数据 */
|
|
3792
|
-
getDanmakuList(data
|
|
3900
|
+
getDanmakuList(data) {
|
|
3793
3901
|
return `https://www-hj.douyin.com/aweme/v1/web/danmaku/get_v2/?${buildQueryString({
|
|
3794
3902
|
...this.getBaseParams(),
|
|
3795
3903
|
app_name: "aweme",
|
|
3796
3904
|
format: "json",
|
|
3797
|
-
group_id: data
|
|
3798
|
-
item_id: data
|
|
3799
|
-
start_time: data
|
|
3800
|
-
end_time: data
|
|
3801
|
-
duration: data
|
|
3905
|
+
group_id: data.aweme_id,
|
|
3906
|
+
item_id: data.aweme_id,
|
|
3907
|
+
start_time: data.start_time ?? "0",
|
|
3908
|
+
end_time: data.end_time ?? "32000",
|
|
3909
|
+
duration: data.duration,
|
|
3802
3910
|
update_version_code: "170400",
|
|
3803
3911
|
pc_libra_divert: "Windows",
|
|
3804
3912
|
support_h265: "1",
|
|
@@ -3831,7 +3939,6 @@ const createDouyinApiUrls = (userAgent) => {
|
|
|
3831
3939
|
};
|
|
3832
3940
|
/** 默认的 DouyinAPI 实例(使用默认浏览器版本 125.0.0.0) */
|
|
3833
3941
|
const douyinApiUrls = new DouyinAPI();
|
|
3834
|
-
|
|
3835
3942
|
//#endregion
|
|
3836
3943
|
//#region src/platform/douyin/getdata.ts
|
|
3837
3944
|
/**
|
|
@@ -3855,7 +3962,6 @@ const douyinApiUrls = new DouyinAPI();
|
|
|
3855
3962
|
const getSignature = (url, signType = "a_bogus", userAgent) => {
|
|
3856
3963
|
switch (signType) {
|
|
3857
3964
|
case "x_bogus": return douyinSign.XB(url, userAgent);
|
|
3858
|
-
case "a_bogus":
|
|
3859
3965
|
default: return douyinSign.AB(url, userAgent);
|
|
3860
3966
|
}
|
|
3861
3967
|
};
|
|
@@ -3868,7 +3974,6 @@ const getSignature = (url, signType = "a_bogus", userAgent) => {
|
|
|
3868
3974
|
const getSignParamName = (signType = "a_bogus") => {
|
|
3869
3975
|
switch (signType) {
|
|
3870
3976
|
case "x_bogus": return "X-Bogus";
|
|
3871
|
-
case "a_bogus":
|
|
3872
3977
|
default: return "a_bogus";
|
|
3873
3978
|
}
|
|
3874
3979
|
};
|
|
@@ -3892,7 +3997,7 @@ const buildSignedUrl = (url, signType = "a_bogus", userAgent) => {
|
|
|
3892
3997
|
* @param requestConfig - 外部请求配置(优先级最高)
|
|
3893
3998
|
* @returns 返回抖音数据
|
|
3894
3999
|
*/
|
|
3895
|
-
const DouyinData = async (data
|
|
4000
|
+
const DouyinData = async (data, cookie, requestConfig) => {
|
|
3896
4001
|
const defHeaders = getDouyinDefaultConfig(cookie)["headers"];
|
|
3897
4002
|
const baseRequestConfig = {
|
|
3898
4003
|
method: "GET",
|
|
@@ -3904,28 +4009,28 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
3904
4009
|
}
|
|
3905
4010
|
};
|
|
3906
4011
|
const userAgent = baseRequestConfig.headers?.["User-Agent"];
|
|
3907
|
-
const douyinApiUrls
|
|
3908
|
-
const signType = data
|
|
3909
|
-
switch (data
|
|
4012
|
+
const douyinApiUrls = createDouyinApiUrls(userAgent);
|
|
4013
|
+
const signType = data.signType ?? "a_bogus";
|
|
4014
|
+
switch (data.methodType) {
|
|
3910
4015
|
case "textWork":
|
|
3911
4016
|
case "parseWork":
|
|
3912
4017
|
case "videoWork":
|
|
3913
4018
|
case "imageAlbumWork":
|
|
3914
4019
|
case "slidesWork": {
|
|
3915
|
-
const url = douyinApiUrls
|
|
3916
|
-
return await GlobalGetData$3(data
|
|
4020
|
+
const url = douyinApiUrls.getWorkDetail({ aweme_id: data.aweme_id });
|
|
4021
|
+
return await GlobalGetData$3(data.methodType, {
|
|
3917
4022
|
...baseRequestConfig,
|
|
3918
4023
|
url: buildSignedUrl(url, signType, userAgent)
|
|
3919
4024
|
});
|
|
3920
4025
|
}
|
|
3921
4026
|
case "comments": {
|
|
3922
|
-
const urlGenerator = (params) => douyinApiUrls
|
|
4027
|
+
const urlGenerator = (params) => douyinApiUrls.getComments(params);
|
|
3923
4028
|
return await fetchPaginatedData({
|
|
3924
|
-
type: data
|
|
4029
|
+
type: data.methodType,
|
|
3925
4030
|
apiUrlGenerator: urlGenerator,
|
|
3926
4031
|
params: {
|
|
3927
|
-
...data
|
|
3928
|
-
cursor: data
|
|
4032
|
+
...data,
|
|
4033
|
+
cursor: data.cursor ?? 0
|
|
3929
4034
|
},
|
|
3930
4035
|
maxPageSize: 50,
|
|
3931
4036
|
requestConfig: baseRequestConfig,
|
|
@@ -3944,13 +4049,13 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
3944
4049
|
});
|
|
3945
4050
|
}
|
|
3946
4051
|
case "commentReplies": {
|
|
3947
|
-
const urlGenerator = (params) => douyinApiUrls
|
|
4052
|
+
const urlGenerator = (params) => douyinApiUrls.getCommentReplies(params);
|
|
3948
4053
|
return await fetchPaginatedData({
|
|
3949
|
-
type: data
|
|
4054
|
+
type: data.methodType,
|
|
3950
4055
|
apiUrlGenerator: urlGenerator,
|
|
3951
4056
|
params: {
|
|
3952
|
-
...data
|
|
3953
|
-
cursor: data
|
|
4057
|
+
...data,
|
|
4058
|
+
cursor: data.cursor ?? 0
|
|
3954
4059
|
},
|
|
3955
4060
|
maxPageSize: 3,
|
|
3956
4061
|
requestConfig: baseRequestConfig,
|
|
@@ -3969,41 +4074,41 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
3969
4074
|
});
|
|
3970
4075
|
}
|
|
3971
4076
|
case "userProfile": {
|
|
3972
|
-
const url = douyinApiUrls
|
|
4077
|
+
const url = douyinApiUrls.getUserProfile({ sec_uid: data.sec_uid });
|
|
3973
4078
|
const customConfig = {
|
|
3974
4079
|
...baseRequestConfig,
|
|
3975
4080
|
headers: {
|
|
3976
4081
|
...baseRequestConfig.headers,
|
|
3977
|
-
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data
|
|
4082
|
+
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data.sec_uid}` }
|
|
3978
4083
|
}
|
|
3979
4084
|
};
|
|
3980
|
-
return await GlobalGetData$3(data
|
|
4085
|
+
return await GlobalGetData$3(data.methodType, {
|
|
3981
4086
|
...customConfig,
|
|
3982
4087
|
url: buildSignedUrl(url, signType, userAgent)
|
|
3983
4088
|
});
|
|
3984
4089
|
}
|
|
3985
4090
|
case "emojiList": {
|
|
3986
|
-
const url = douyinApiUrls
|
|
3987
|
-
return await GlobalGetData$3(data
|
|
4091
|
+
const url = douyinApiUrls.getEmojiList();
|
|
4092
|
+
return await GlobalGetData$3(data.methodType, {
|
|
3988
4093
|
...baseRequestConfig,
|
|
3989
4094
|
url
|
|
3990
4095
|
});
|
|
3991
4096
|
}
|
|
3992
4097
|
case "userVideoList": {
|
|
3993
|
-
const urlGenerator = (params) => douyinApiUrls
|
|
4098
|
+
const urlGenerator = (params) => douyinApiUrls.getUserVideoList(params);
|
|
3994
4099
|
return await fetchPaginatedData({
|
|
3995
|
-
type: data
|
|
4100
|
+
type: data.methodType,
|
|
3996
4101
|
apiUrlGenerator: urlGenerator,
|
|
3997
4102
|
params: {
|
|
3998
|
-
...data
|
|
3999
|
-
max_cursor: data
|
|
4103
|
+
...data,
|
|
4104
|
+
max_cursor: data.max_cursor
|
|
4000
4105
|
},
|
|
4001
4106
|
maxPageSize: 18,
|
|
4002
4107
|
requestConfig: {
|
|
4003
4108
|
...baseRequestConfig,
|
|
4004
4109
|
headers: {
|
|
4005
4110
|
...baseRequestConfig.headers,
|
|
4006
|
-
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data
|
|
4111
|
+
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data.sec_uid}` }
|
|
4007
4112
|
}
|
|
4008
4113
|
},
|
|
4009
4114
|
signType,
|
|
@@ -4020,20 +4125,20 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
4020
4125
|
});
|
|
4021
4126
|
}
|
|
4022
4127
|
case "userFavoriteList": {
|
|
4023
|
-
const urlGenerator = (params) => douyinApiUrls
|
|
4128
|
+
const urlGenerator = (params) => douyinApiUrls.getUserFavoriteList(params);
|
|
4024
4129
|
return await fetchPaginatedData({
|
|
4025
|
-
type: data
|
|
4130
|
+
type: data.methodType,
|
|
4026
4131
|
apiUrlGenerator: urlGenerator,
|
|
4027
4132
|
params: {
|
|
4028
|
-
...data
|
|
4029
|
-
max_cursor: data
|
|
4133
|
+
...data,
|
|
4134
|
+
max_cursor: data.max_cursor
|
|
4030
4135
|
},
|
|
4031
4136
|
maxPageSize: 18,
|
|
4032
4137
|
requestConfig: {
|
|
4033
4138
|
...baseRequestConfig,
|
|
4034
4139
|
headers: {
|
|
4035
4140
|
...baseRequestConfig.headers,
|
|
4036
|
-
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data
|
|
4141
|
+
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data.sec_uid}` }
|
|
4037
4142
|
}
|
|
4038
4143
|
},
|
|
4039
4144
|
signType,
|
|
@@ -4050,20 +4155,20 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
4050
4155
|
});
|
|
4051
4156
|
}
|
|
4052
4157
|
case "userRecommendList": {
|
|
4053
|
-
const urlGenerator = (params) => douyinApiUrls
|
|
4158
|
+
const urlGenerator = (params) => douyinApiUrls.getUserRecommendList(params);
|
|
4054
4159
|
return await fetchPaginatedData({
|
|
4055
|
-
type: data
|
|
4160
|
+
type: data.methodType,
|
|
4056
4161
|
apiUrlGenerator: urlGenerator,
|
|
4057
4162
|
params: {
|
|
4058
|
-
...data
|
|
4059
|
-
max_cursor: data
|
|
4163
|
+
...data,
|
|
4164
|
+
max_cursor: data.max_cursor
|
|
4060
4165
|
},
|
|
4061
4166
|
maxPageSize: 18,
|
|
4062
4167
|
requestConfig: {
|
|
4063
4168
|
...baseRequestConfig,
|
|
4064
4169
|
headers: {
|
|
4065
4170
|
...baseRequestConfig.headers,
|
|
4066
|
-
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data
|
|
4171
|
+
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/user/${data.sec_uid}` }
|
|
4067
4172
|
}
|
|
4068
4173
|
},
|
|
4069
4174
|
signType,
|
|
@@ -4080,22 +4185,22 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
4080
4185
|
});
|
|
4081
4186
|
}
|
|
4082
4187
|
case "suggestWords": {
|
|
4083
|
-
const url = douyinApiUrls
|
|
4188
|
+
const url = douyinApiUrls.getSuggestWords({ query: data.query });
|
|
4084
4189
|
const customConfig = {
|
|
4085
4190
|
...baseRequestConfig,
|
|
4086
4191
|
headers: {
|
|
4087
4192
|
...baseRequestConfig.headers,
|
|
4088
|
-
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/search/${encodeURIComponent(String(data
|
|
4193
|
+
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://www.douyin.com/search/${encodeURIComponent(String(data.query))}` }
|
|
4089
4194
|
}
|
|
4090
4195
|
};
|
|
4091
|
-
return await GlobalGetData$3(data
|
|
4196
|
+
return await GlobalGetData$3(data.methodType, {
|
|
4092
4197
|
...customConfig,
|
|
4093
4198
|
url: buildSignedUrl(url, signType, userAgent)
|
|
4094
4199
|
});
|
|
4095
4200
|
}
|
|
4096
4201
|
case "search": {
|
|
4097
|
-
const searchType = data
|
|
4098
|
-
const refererUrl = searchType === "user" ? `https://www.douyin.com/search/${encodeURIComponent(String(data
|
|
4202
|
+
const searchType = data.type ?? "general";
|
|
4203
|
+
const refererUrl = searchType === "user" ? `https://www.douyin.com/search/${encodeURIComponent(String(data.query))}?type=user` : searchType === "video" ? `https://www.douyin.com/search/${encodeURIComponent(String(data.query))}?type=video` : `https://www.douyin.com/root/search/${encodeURIComponent(String(data.query))}`;
|
|
4099
4204
|
const customConfig = {
|
|
4100
4205
|
...baseRequestConfig,
|
|
4101
4206
|
headers: {
|
|
@@ -4106,12 +4211,12 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
4106
4211
|
const isUserSearch = searchType === "user";
|
|
4107
4212
|
const isVideoSearch = searchType === "video";
|
|
4108
4213
|
return await fetchPaginatedData({
|
|
4109
|
-
type: data
|
|
4110
|
-
apiUrlGenerator: (params) => douyinApiUrls
|
|
4214
|
+
type: data.methodType,
|
|
4215
|
+
apiUrlGenerator: (params) => douyinApiUrls.search(params),
|
|
4111
4216
|
params: {
|
|
4112
|
-
query: data
|
|
4113
|
-
type: data
|
|
4114
|
-
number: data
|
|
4217
|
+
query: data.query,
|
|
4218
|
+
type: data.type,
|
|
4219
|
+
number: data.number ?? 10,
|
|
4115
4220
|
search_id: ""
|
|
4116
4221
|
},
|
|
4117
4222
|
maxPageSize: 15,
|
|
@@ -4161,17 +4266,17 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
4161
4266
|
if (isInvalidResponse) {
|
|
4162
4267
|
const desc = `抖音${typeStr}搜索返回无有效数据,疑似触发反爬机制,你的抖音Cookie可能已经失效!`;
|
|
4163
4268
|
const warningMessage = `
|
|
4164
|
-
获取响应数据失败!原因:${
|
|
4165
|
-
请求类型:「${data
|
|
4166
|
-
搜索关键词:「${data
|
|
4269
|
+
获取响应数据失败!原因:${typeStr}搜索返回无有效数据,疑似触发反爬机制
|
|
4270
|
+
请求类型:「${data.methodType}」
|
|
4271
|
+
搜索关键词:「${data.query}」
|
|
4167
4272
|
请求URL:${url}
|
|
4168
4273
|
`;
|
|
4169
4274
|
return {
|
|
4170
|
-
code:
|
|
4275
|
+
code: "INVALID_COOKIE",
|
|
4171
4276
|
data: raw,
|
|
4172
4277
|
amagiError: {
|
|
4173
4278
|
errorDescription: desc,
|
|
4174
|
-
requestType: data
|
|
4279
|
+
requestType: data.methodType ?? "未知请求类型",
|
|
4175
4280
|
requestUrl: url
|
|
4176
4281
|
},
|
|
4177
4282
|
amagiMessage: warningMessage
|
|
@@ -4180,17 +4285,17 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
4180
4285
|
if (!list || list.length === 0) {
|
|
4181
4286
|
const desc = `抖音${typeStr}搜索接口第一次请求就返回空数组,可能该关键词无搜索结果或触发风控限制,你的抖音Cookie可能已经失效!`;
|
|
4182
4287
|
const warningMessage = `
|
|
4183
|
-
获取响应数据失败!原因:${
|
|
4184
|
-
请求类型:「${data
|
|
4185
|
-
搜索关键词:「${data
|
|
4288
|
+
获取响应数据失败!原因:${typeStr}搜索接口第一次请求就返回空数组,你的抖音Cookie可能已经失效!
|
|
4289
|
+
请求类型:「${data.methodType}」
|
|
4290
|
+
搜索关键词:「${data.query}」
|
|
4186
4291
|
请求URL:${url}
|
|
4187
4292
|
`;
|
|
4188
|
-
|
|
4293
|
+
emitLogWarn(warningMessage);
|
|
4189
4294
|
return {
|
|
4190
4295
|
data: raw,
|
|
4191
4296
|
amagiError: {
|
|
4192
4297
|
errorDescription: desc,
|
|
4193
|
-
requestType: data
|
|
4298
|
+
requestType: data.methodType ?? "未知请求类型",
|
|
4194
4299
|
requestUrl: url
|
|
4195
4300
|
},
|
|
4196
4301
|
amagiMessage: warningMessage
|
|
@@ -4211,57 +4316,57 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
4211
4316
|
});
|
|
4212
4317
|
}
|
|
4213
4318
|
case "dynamicEmojiList": {
|
|
4214
|
-
const url = douyinApiUrls
|
|
4215
|
-
return await GlobalGetData$3(data
|
|
4319
|
+
const url = douyinApiUrls.getDynamicEmojiList();
|
|
4320
|
+
return await GlobalGetData$3(data.methodType, {
|
|
4216
4321
|
...baseRequestConfig,
|
|
4217
4322
|
url: buildSignedUrl(url, signType, userAgent)
|
|
4218
4323
|
});
|
|
4219
4324
|
}
|
|
4220
4325
|
case "musicInfo": {
|
|
4221
|
-
const url = douyinApiUrls
|
|
4222
|
-
return await GlobalGetData$3(data
|
|
4326
|
+
const url = douyinApiUrls.getMusicInfo({ music_id: data.music_id });
|
|
4327
|
+
return await GlobalGetData$3(data.methodType, {
|
|
4223
4328
|
...baseRequestConfig,
|
|
4224
4329
|
url: buildSignedUrl(url, signType, userAgent)
|
|
4225
4330
|
});
|
|
4226
4331
|
}
|
|
4227
4332
|
case "liveRoomInfo": {
|
|
4228
|
-
let url = douyinApiUrls
|
|
4229
|
-
room_id: data
|
|
4230
|
-
web_rid: data
|
|
4333
|
+
let url = douyinApiUrls.getLiveRoomInfo({
|
|
4334
|
+
room_id: data.room_id,
|
|
4335
|
+
web_rid: data.web_rid
|
|
4231
4336
|
});
|
|
4232
4337
|
const liveCustomConfig = {
|
|
4233
4338
|
...baseRequestConfig,
|
|
4234
4339
|
url: buildSignedUrl(url, signType, userAgent),
|
|
4235
4340
|
headers: {
|
|
4236
4341
|
...baseRequestConfig.headers,
|
|
4237
|
-
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://live.douyin.com/${data
|
|
4342
|
+
...(!requestConfig?.headers || !("Referer" in requestConfig.headers)) && { Referer: `https://live.douyin.com/${data.web_rid}` }
|
|
4238
4343
|
}
|
|
4239
4344
|
};
|
|
4240
|
-
return await GlobalGetData$3(data
|
|
4345
|
+
return await GlobalGetData$3(data.methodType, {
|
|
4241
4346
|
...liveCustomConfig,
|
|
4242
4347
|
url: buildSignedUrl(url, signType, userAgent)
|
|
4243
4348
|
});
|
|
4244
4349
|
}
|
|
4245
4350
|
case "loginQrcode": {
|
|
4246
|
-
const url = douyinApiUrls
|
|
4247
|
-
return await GlobalGetData$3(data
|
|
4351
|
+
const url = douyinApiUrls.getLoginQrcode({ verify_fp: data.verify_fp });
|
|
4352
|
+
return await GlobalGetData$3(data.methodType, {
|
|
4248
4353
|
...baseRequestConfig,
|
|
4249
4354
|
url: buildSignedUrl(url, signType, userAgent)
|
|
4250
4355
|
});
|
|
4251
4356
|
}
|
|
4252
4357
|
case "danmakuList": {
|
|
4253
4358
|
const MAX_SEGMENT_DURATION = 32e3;
|
|
4254
|
-
const startTime = data
|
|
4255
|
-
const endTime = data
|
|
4359
|
+
const startTime = data.start_time ?? 0;
|
|
4360
|
+
const endTime = data.end_time ?? data.duration;
|
|
4256
4361
|
const totalDuration = endTime - startTime;
|
|
4257
4362
|
if (totalDuration <= MAX_SEGMENT_DURATION) {
|
|
4258
|
-
const url = douyinApiUrls
|
|
4259
|
-
aweme_id: data
|
|
4363
|
+
const url = douyinApiUrls.getDanmakuList({
|
|
4364
|
+
aweme_id: data.aweme_id,
|
|
4260
4365
|
start_time: startTime,
|
|
4261
4366
|
end_time: endTime,
|
|
4262
|
-
duration: data
|
|
4367
|
+
duration: data.duration
|
|
4263
4368
|
});
|
|
4264
|
-
return await GlobalGetData$3(data
|
|
4369
|
+
return await GlobalGetData$3(data.methodType, {
|
|
4265
4370
|
...baseRequestConfig,
|
|
4266
4371
|
url: buildSignedUrl(url, signType, userAgent)
|
|
4267
4372
|
});
|
|
@@ -4276,23 +4381,23 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
4276
4381
|
});
|
|
4277
4382
|
currentStart = currentEnd;
|
|
4278
4383
|
}
|
|
4279
|
-
|
|
4384
|
+
emitLogDebug(`弹幕数据需要分${segments.length}段获取,总时长:${totalDuration}ms`);
|
|
4280
4385
|
const segmentPromises = segments.map(async (segment, index) => {
|
|
4281
|
-
const url = douyinApiUrls
|
|
4282
|
-
aweme_id: data
|
|
4386
|
+
const url = douyinApiUrls.getDanmakuList({
|
|
4387
|
+
aweme_id: data.aweme_id,
|
|
4283
4388
|
start_time: segment.start,
|
|
4284
4389
|
end_time: segment.end,
|
|
4285
|
-
duration: data
|
|
4390
|
+
duration: data.duration
|
|
4286
4391
|
});
|
|
4287
4392
|
try {
|
|
4288
|
-
const segmentData = await GlobalGetData$3(`${data
|
|
4393
|
+
const segmentData = await GlobalGetData$3(`${data.methodType}-segment${index + 1}`, {
|
|
4289
4394
|
...baseRequestConfig,
|
|
4290
4395
|
url: buildSignedUrl(url, signType, userAgent)
|
|
4291
4396
|
});
|
|
4292
|
-
|
|
4397
|
+
emitLogDebug(`弹幕第${index + 1}段获取成功 (${segment.start}ms-${segment.end}ms)`);
|
|
4293
4398
|
return segmentData;
|
|
4294
4399
|
} catch (error) {
|
|
4295
|
-
|
|
4400
|
+
emitLogDebug(`弹幕第${index + 1}段获取失败 (${segment.start}ms-${segment.end}ms):`, error);
|
|
4296
4401
|
return null;
|
|
4297
4402
|
}
|
|
4298
4403
|
});
|
|
@@ -4321,19 +4426,19 @@ const DouyinData = async (data$1, cookie, requestConfig) => {
|
|
|
4321
4426
|
extra: finalExtra,
|
|
4322
4427
|
log_pb: finalLogPb
|
|
4323
4428
|
};
|
|
4324
|
-
|
|
4429
|
+
emitLogDebug(`弹幕数据合并完成,共获取${mergedDanmakuList.length}条弹幕`);
|
|
4325
4430
|
return finalDanmakuData;
|
|
4326
4431
|
}
|
|
4327
4432
|
default: {
|
|
4328
|
-
const customUrl = data
|
|
4433
|
+
const customUrl = data.custom_url;
|
|
4329
4434
|
if (typeof customUrl === "string" && customUrl.length > 0) {
|
|
4330
4435
|
const url = buildSignedUrl(customUrl, signType, userAgent);
|
|
4331
|
-
return await GlobalGetData$3(data
|
|
4436
|
+
return await GlobalGetData$3(data.methodType ?? "customRequest", {
|
|
4332
4437
|
...baseRequestConfig,
|
|
4333
4438
|
url
|
|
4334
4439
|
});
|
|
4335
4440
|
}
|
|
4336
|
-
|
|
4441
|
+
emitLogWarn(`未知的抖音数据接口:「${data.methodType}」`);
|
|
4337
4442
|
return null;
|
|
4338
4443
|
}
|
|
4339
4444
|
}
|
|
@@ -4401,14 +4506,14 @@ const GlobalGetData$3 = async (type, config) => {
|
|
|
4401
4506
|
requestUrl: config.url
|
|
4402
4507
|
};
|
|
4403
4508
|
warningMessage = `
|
|
4404
|
-
|
|
4509
|
+
获取响应数据失败!原因:接口返回内容为空,你的抖音ck可能已经失效!
|
|
4405
4510
|
请求类型:「${type}」
|
|
4406
4511
|
请求URL:${config.url}
|
|
4407
4512
|
`;
|
|
4408
|
-
|
|
4513
|
+
emitLogWarn(warningMessage);
|
|
4409
4514
|
const cookieError = new Error(Err.errorDescription);
|
|
4410
4515
|
Object.assign(cookieError, {
|
|
4411
|
-
code:
|
|
4516
|
+
code: "INVALID_COOKIE",
|
|
4412
4517
|
data: result,
|
|
4413
4518
|
amagiError: Err
|
|
4414
4519
|
});
|
|
@@ -4422,14 +4527,14 @@ const GlobalGetData$3 = async (type, config) => {
|
|
|
4422
4527
|
requestUrl: config.url
|
|
4423
4528
|
};
|
|
4424
4529
|
warningMessage = `
|
|
4425
|
-
获取响应数据失败!原因:${
|
|
4530
|
+
获取响应数据失败!原因:${filterReason}
|
|
4426
4531
|
请求类型:「${type}」
|
|
4427
4532
|
请求URL:${config.url}
|
|
4428
4533
|
`;
|
|
4429
|
-
|
|
4534
|
+
emitLogWarn(warningMessage);
|
|
4430
4535
|
const filterError = new Error(Err.errorDescription);
|
|
4431
4536
|
Object.assign(filterError, {
|
|
4432
|
-
code:
|
|
4537
|
+
code: "CONTENT_FILTERED",
|
|
4433
4538
|
data: result,
|
|
4434
4539
|
amagiError: Err
|
|
4435
4540
|
});
|
|
@@ -4442,7 +4547,7 @@ const GlobalGetData$3 = async (type, config) => {
|
|
|
4442
4547
|
amagiMessage: warningMessage
|
|
4443
4548
|
};
|
|
4444
4549
|
return {
|
|
4445
|
-
code:
|
|
4550
|
+
code: "UNKNOWN_ERROR",
|
|
4446
4551
|
data: null,
|
|
4447
4552
|
amagiError: {
|
|
4448
4553
|
errorDescription: "未知错误",
|
|
@@ -4481,7 +4586,6 @@ const parseDouyinMultiJson = (raw) => {
|
|
|
4481
4586
|
const filterSearchResponses = (objs) => {
|
|
4482
4587
|
return objs.filter((o) => o && typeof o.cursor === "number" && typeof o.has_more === "number" && Array.isArray(o.data));
|
|
4483
4588
|
};
|
|
4484
|
-
|
|
4485
4589
|
//#endregion
|
|
4486
4590
|
//#region src/model/fetchers/douyin/internal.ts
|
|
4487
4591
|
/**
|
|
@@ -4533,7 +4637,6 @@ async function fetchDouyinInternal(methodType, options, config) {
|
|
|
4533
4637
|
throw new Error(`抖音数据获取失败: ${errorMessage}`);
|
|
4534
4638
|
}
|
|
4535
4639
|
}
|
|
4536
|
-
|
|
4537
4640
|
//#endregion
|
|
4538
4641
|
//#region src/model/fetchers/douyin/comment.ts
|
|
4539
4642
|
/**
|
|
@@ -4581,7 +4684,6 @@ async function fetchCommentReplies(options, cookie, requestConfig) {
|
|
|
4581
4684
|
requestConfig
|
|
4582
4685
|
});
|
|
4583
4686
|
}
|
|
4584
|
-
|
|
4585
4687
|
//#endregion
|
|
4586
4688
|
//#region src/model/fetchers/douyin/misc.ts
|
|
4587
4689
|
/**
|
|
@@ -4678,7 +4780,6 @@ async function fetchDynamicEmojiList(options, cookie, requestConfig) {
|
|
|
4678
4780
|
requestConfig
|
|
4679
4781
|
});
|
|
4680
4782
|
}
|
|
4681
|
-
|
|
4682
4783
|
//#endregion
|
|
4683
4784
|
//#region src/model/fetchers/douyin/search.ts
|
|
4684
4785
|
/**
|
|
@@ -4727,7 +4828,6 @@ async function fetchSuggestWords(options, cookie, requestConfig) {
|
|
|
4727
4828
|
requestConfig
|
|
4728
4829
|
});
|
|
4729
4830
|
}
|
|
4730
|
-
|
|
4731
4831
|
//#endregion
|
|
4732
4832
|
//#region src/model/fetchers/douyin/user.ts
|
|
4733
4833
|
/**
|
|
@@ -4812,7 +4912,6 @@ async function fetchUserRecommendList(options, cookie, requestConfig) {
|
|
|
4812
4912
|
requestConfig
|
|
4813
4913
|
});
|
|
4814
4914
|
}
|
|
4815
|
-
|
|
4816
4915
|
//#endregion
|
|
4817
4916
|
//#region src/model/fetchers/douyin/video.ts
|
|
4818
4917
|
/**
|
|
@@ -4929,7 +5028,6 @@ async function fetchDanmakuList(options, cookie, requestConfig) {
|
|
|
4929
5028
|
requestConfig
|
|
4930
5029
|
});
|
|
4931
5030
|
}
|
|
4932
|
-
|
|
4933
5031
|
//#endregion
|
|
4934
5032
|
//#region src/model/fetchers/douyin/bound.ts
|
|
4935
5033
|
/**
|
|
@@ -4968,7 +5066,6 @@ function createBoundDouyinFetcher(cookie, requestConfig) {
|
|
|
4968
5066
|
fetchDynamicEmojiList: (options, reqConfig) => fetchDynamicEmojiList(options, cookie, reqConfig ?? requestConfig)
|
|
4969
5067
|
};
|
|
4970
5068
|
}
|
|
4971
|
-
|
|
4972
5069
|
//#endregion
|
|
4973
5070
|
//#region src/model/fetchers/douyin/index.ts
|
|
4974
5071
|
/**
|
|
@@ -5006,7 +5103,6 @@ const douyinFetcher = {
|
|
|
5006
5103
|
fetchEmojiList: fetchEmojiList$2,
|
|
5007
5104
|
fetchDynamicEmojiList
|
|
5008
5105
|
};
|
|
5009
|
-
|
|
5010
5106
|
//#endregion
|
|
5011
5107
|
//#region src/platform/kuaishou/API.ts
|
|
5012
5108
|
/**
|
|
@@ -5044,14 +5140,19 @@ var API = class {
|
|
|
5044
5140
|
* @param data - 作品参数
|
|
5045
5141
|
* @returns 请求配置
|
|
5046
5142
|
*/
|
|
5047
|
-
videoWork(data
|
|
5143
|
+
videoWork(data) {
|
|
5048
5144
|
return {
|
|
5145
|
+
/** 接口类型 */
|
|
5049
5146
|
type: "visionVideoDetail",
|
|
5147
|
+
/** 请求url */
|
|
5050
5148
|
url: "https://www.kuaishou.com/graphql",
|
|
5149
|
+
/** 请求参数 */
|
|
5051
5150
|
body: {
|
|
5151
|
+
/** 接口类型 */
|
|
5052
5152
|
operationName: "visionVideoDetail",
|
|
5053
5153
|
variables: {
|
|
5054
|
-
|
|
5154
|
+
/** 作品ID */
|
|
5155
|
+
photoId: data.photoId,
|
|
5055
5156
|
page: "detail"
|
|
5056
5157
|
},
|
|
5057
5158
|
query: "query visionVideoDetail($photoId: String, $type: String, $page: String, $webPageArea: String) {\n visionVideoDetail(photoId: $photoId, type: $type, page: $page, webPageArea: $webPageArea) {\n status\n type\n author {\n id\n name\n following\n headerUrl\n __typename\n }\n photo {\n id\n duration\n caption\n likeCount\n realLikeCount\n coverUrl\n photoUrl\n liked\n timestamp\n expTag\n llsid\n viewCount\n videoRatio\n stereoType\n musicBlocked\n manifest {\n mediaType\n businessType\n version\n adaptationSet {\n id\n duration\n representation {\n id\n defaultSelect\n backupUrl\n codecs\n url\n height\n width\n avgBitrate\n maxBitrate\n m3u8Slice\n qualityType\n qualityLabel\n frameRate\n featureP2sp\n hidden\n disableAdaptive\n __typename\n }\n __typename\n }\n __typename\n }\n manifestH265\n photoH265Url\n coronaCropManifest\n coronaCropManifestH265\n croppedPhotoH265Url\n croppedPhotoUrl\n videoResource\n __typename\n }\n tags {\n type\n name\n __typename\n }\n commentLimit {\n canAddComment\n __typename\n }\n llsid\n danmakuSwitch\n __typename\n }\n}\n"
|
|
@@ -5063,14 +5164,14 @@ var API = class {
|
|
|
5063
5164
|
* @param data - 评论参数
|
|
5064
5165
|
* @returns 请求配置
|
|
5065
5166
|
*/
|
|
5066
|
-
comments(data
|
|
5167
|
+
comments(data) {
|
|
5067
5168
|
return {
|
|
5068
5169
|
type: "commentListQuery",
|
|
5069
5170
|
url: "https://www.kuaishou.com/graphql",
|
|
5070
5171
|
body: {
|
|
5071
5172
|
operationName: "commentListQuery",
|
|
5072
5173
|
variables: {
|
|
5073
|
-
photoId: data
|
|
5174
|
+
photoId: data.photoId,
|
|
5074
5175
|
pcursor: ""
|
|
5075
5176
|
},
|
|
5076
5177
|
query: "query commentListQuery($photoId: String, $pcursor: String) {\n visionCommentList(photoId: $photoId, pcursor: $pcursor) {\n commentCount\n pcursor\n rootComments {\n commentId\n authorId\n authorName\n content\n headurl\n timestamp\n likedCount\n realLikedCount\n liked\n status\n authorLiked\n subCommentCount\n subCommentsPcursor\n subComments {\n commentId\n authorId\n authorName\n content\n headurl\n timestamp\n likedCount\n realLikedCount\n liked\n status\n authorLiked\n replyToUserName\n replyTo\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"
|
|
@@ -5086,10 +5187,10 @@ var API = class {
|
|
|
5086
5187
|
* @param data - 用户主页参数
|
|
5087
5188
|
* @returns 请求配置
|
|
5088
5189
|
*/
|
|
5089
|
-
userInfoById(data
|
|
5190
|
+
userInfoById(data) {
|
|
5090
5191
|
return createKuaishouLiveApiRequest("userInfoById", "/live_api/baseuser/userinfo/byid", {
|
|
5091
5192
|
caver: 2,
|
|
5092
|
-
principalId: data
|
|
5193
|
+
principalId: data.principalId
|
|
5093
5194
|
}, { signPath: "/rest/k/user/info" });
|
|
5094
5195
|
}
|
|
5095
5196
|
/**
|
|
@@ -5097,10 +5198,10 @@ var API = class {
|
|
|
5097
5198
|
* @param data - 用户主页参数
|
|
5098
5199
|
* @returns 请求配置
|
|
5099
5200
|
*/
|
|
5100
|
-
userSensitiveInfo(data
|
|
5201
|
+
userSensitiveInfo(data) {
|
|
5101
5202
|
return createKuaishouLiveApiRequest("userSensitiveInfo", "/live_api/baseuser/userinfo/sensitive", {
|
|
5102
5203
|
caver: 2,
|
|
5103
|
-
principalId: data
|
|
5204
|
+
principalId: data.principalId
|
|
5104
5205
|
}, { signPath: "/rest/k/user/info/sensitive" });
|
|
5105
5206
|
}
|
|
5106
5207
|
/**
|
|
@@ -5108,13 +5209,13 @@ var API = class {
|
|
|
5108
5209
|
* @param data - 用户主页参数
|
|
5109
5210
|
* @returns 请求配置
|
|
5110
5211
|
*/
|
|
5111
|
-
profilePublic(data
|
|
5212
|
+
profilePublic(data) {
|
|
5112
5213
|
return createKuaishouLiveApiRequest("profilePublic", "/live_api/profile/public", {
|
|
5113
5214
|
caver: 2,
|
|
5114
|
-
count: "count" in data
|
|
5215
|
+
count: "count" in data ? data.count ?? 12 : 12,
|
|
5115
5216
|
hasMore: true,
|
|
5116
|
-
pcursor: "pcursor" in data
|
|
5117
|
-
principalId: data
|
|
5217
|
+
pcursor: "pcursor" in data ? data.pcursor ?? "" : "",
|
|
5218
|
+
principalId: data.principalId,
|
|
5118
5219
|
privacy: "public"
|
|
5119
5220
|
}, { signPath: "/rest/k/feed/profile" });
|
|
5120
5221
|
}
|
|
@@ -5127,9 +5228,9 @@ var API = class {
|
|
|
5127
5228
|
* @param data - 用户作品列表参数
|
|
5128
5229
|
* @returns 请求配置
|
|
5129
5230
|
*/
|
|
5130
|
-
userWorkList(data
|
|
5231
|
+
userWorkList(data) {
|
|
5131
5232
|
return {
|
|
5132
|
-
...this.profilePublic(data
|
|
5233
|
+
...this.profilePublic(data),
|
|
5133
5234
|
type: "userWorkList"
|
|
5134
5235
|
};
|
|
5135
5236
|
}
|
|
@@ -5141,13 +5242,13 @@ var API = class {
|
|
|
5141
5242
|
* @param data - 用户主页参数
|
|
5142
5243
|
* @returns 请求配置
|
|
5143
5244
|
*/
|
|
5144
|
-
profilePrivate(data
|
|
5245
|
+
profilePrivate(data) {
|
|
5145
5246
|
return createKuaishouLiveApiRequest("profilePrivate", "/live_api/profile/private", {
|
|
5146
5247
|
caver: 2,
|
|
5147
5248
|
count: 12,
|
|
5148
5249
|
hasMore: true,
|
|
5149
5250
|
pcursor: "",
|
|
5150
|
-
principalId: data
|
|
5251
|
+
principalId: data.principalId,
|
|
5151
5252
|
privacy: "private"
|
|
5152
5253
|
}, { requiresSign: false });
|
|
5153
5254
|
}
|
|
@@ -5157,13 +5258,13 @@ var API = class {
|
|
|
5157
5258
|
* @param data - 用户主页参数
|
|
5158
5259
|
* @returns 请求配置
|
|
5159
5260
|
*/
|
|
5160
|
-
profileLiked(data
|
|
5261
|
+
profileLiked(data) {
|
|
5161
5262
|
return createKuaishouLiveApiRequest("profileLiked", "/live_api/profile/liked", {
|
|
5162
5263
|
caver: 2,
|
|
5163
5264
|
count: 12,
|
|
5164
5265
|
hasMore: true,
|
|
5165
5266
|
pcursor: "",
|
|
5166
|
-
principalId: data
|
|
5267
|
+
principalId: data.principalId,
|
|
5167
5268
|
privacy: "liked"
|
|
5168
5269
|
}, { requiresSign: false });
|
|
5169
5270
|
}
|
|
@@ -5172,11 +5273,11 @@ var API = class {
|
|
|
5172
5273
|
* @param data - 用户主页参数
|
|
5173
5274
|
* @returns 请求配置
|
|
5174
5275
|
*/
|
|
5175
|
-
profileInterestList(data
|
|
5276
|
+
profileInterestList(data) {
|
|
5176
5277
|
return createKuaishouLiveApiRequest("profileInterestList", "/live_api/profile/interestlist", {
|
|
5177
5278
|
caver: 2,
|
|
5178
5279
|
limit: 4,
|
|
5179
|
-
principalId: data
|
|
5280
|
+
principalId: data.principalId
|
|
5180
5281
|
});
|
|
5181
5282
|
}
|
|
5182
5283
|
/**
|
|
@@ -5187,9 +5288,9 @@ var API = class {
|
|
|
5187
5288
|
* @param data - 用户主页参数
|
|
5188
5289
|
* @returns 请求配置
|
|
5189
5290
|
*/
|
|
5190
|
-
playbackList(data
|
|
5291
|
+
playbackList(data) {
|
|
5191
5292
|
return createKuaishouLiveApiRequest("playbackList", "/live_api/playback/list", {
|
|
5192
|
-
principalId: data
|
|
5293
|
+
principalId: data.principalId,
|
|
5193
5294
|
count: 12,
|
|
5194
5295
|
cursor: "",
|
|
5195
5296
|
hasMore: true
|
|
@@ -5251,8 +5352,8 @@ var API = class {
|
|
|
5251
5352
|
* @param authToken - 私密房间等场景下可能需要的 authToken
|
|
5252
5353
|
* @returns 请求配置
|
|
5253
5354
|
*/
|
|
5254
|
-
liveDetail(data
|
|
5255
|
-
const query = { principalId: data
|
|
5355
|
+
liveDetail(data, authToken) {
|
|
5356
|
+
const query = { principalId: data.principalId };
|
|
5256
5357
|
if (authToken?.trim()) query.authToken = authToken.trim();
|
|
5257
5358
|
return createKuaishouLiveApiRequest("liveDetail", "/live_api/liveroom/livedetail", query, { requiresSign: false });
|
|
5258
5359
|
}
|
|
@@ -5334,7 +5435,6 @@ var API = class {
|
|
|
5334
5435
|
* 该对象只负责返回请求描述,不直接发起网络请求。
|
|
5335
5436
|
*/
|
|
5336
5437
|
const kuaishouApiUrls = new API();
|
|
5337
|
-
|
|
5338
5438
|
//#endregion
|
|
5339
5439
|
//#region src/platform/kuaishou/sign/hudr.ts
|
|
5340
5440
|
const KUAISHOU_HUDR_PREFIX = "HUDR_";
|
|
@@ -5409,6 +5509,8 @@ const encodeBase64Url = (bytes) => {
|
|
|
5409
5509
|
* 数据流而最小化保留的局部算法。
|
|
5410
5510
|
*/
|
|
5411
5511
|
var KuaishouChaChaCipher = class {
|
|
5512
|
+
key;
|
|
5513
|
+
nonce;
|
|
5412
5514
|
wordIndex = 0;
|
|
5413
5515
|
state = new Array(16).fill(0);
|
|
5414
5516
|
constructor(key, nonce) {
|
|
@@ -5528,7 +5630,6 @@ const deriveKuaishouHudrBody = (context) => {
|
|
|
5528
5630
|
nextCount: context.count + 1
|
|
5529
5631
|
};
|
|
5530
5632
|
};
|
|
5531
|
-
|
|
5532
5633
|
//#endregion
|
|
5533
5634
|
//#region src/platform/kuaishou/sign/primitives.ts
|
|
5534
5635
|
const KUAISHOU_BLAKE2S_IV = [
|
|
@@ -6005,7 +6106,6 @@ const transformKuaishouHeHex = (prefixHex, checksumHex) => {
|
|
|
6005
6106
|
output[input.length - 1] = xorKey;
|
|
6006
6107
|
return bytesToLowerHex(output);
|
|
6007
6108
|
};
|
|
6008
|
-
|
|
6009
6109
|
//#endregion
|
|
6010
6110
|
//#region src/platform/kuaishou/sign/he.ts
|
|
6011
6111
|
const KUAISHOU_HE_HEADER_HEX = "4B54";
|
|
@@ -6089,7 +6189,6 @@ const deriveKuaishouPureSignature = (context) => {
|
|
|
6089
6189
|
signResult: `${hudr.full}$HE_${he.finalHex}`
|
|
6090
6190
|
};
|
|
6091
6191
|
};
|
|
6092
|
-
|
|
6093
6192
|
//#endregion
|
|
6094
6193
|
//#region src/platform/kuaishou/sign/helpers.ts
|
|
6095
6194
|
const SIGN_INPUT_SKIP_KEYWORD = "__NS";
|
|
@@ -6178,7 +6277,7 @@ const buildKuaishouHxfalconSignInput = (payload) => {
|
|
|
6178
6277
|
*/
|
|
6179
6278
|
const extractCookieValue = (cookie, key) => {
|
|
6180
6279
|
if (!cookie?.trim()) return "";
|
|
6181
|
-
const pattern =
|
|
6280
|
+
const pattern = new RegExp(`(?:^|;\\s*)${key}=([^;]*)`);
|
|
6182
6281
|
return cookie.match(pattern)?.[1] ?? "";
|
|
6183
6282
|
};
|
|
6184
6283
|
const generateKuaishouAnonymousKwwSeed = () => {
|
|
@@ -6221,7 +6320,6 @@ const deriveKuaishouKww = (cookie) => {
|
|
|
6221
6320
|
if (kwfv1) return kwfv1;
|
|
6222
6321
|
return deriveKuaishouAnonymousKww();
|
|
6223
6322
|
};
|
|
6224
|
-
|
|
6225
6323
|
//#endregion
|
|
6226
6324
|
//#region src/platform/kuaishou/sign/state.ts
|
|
6227
6325
|
const KUAISHOU_DEFAULT_CAT_VERSION = "2";
|
|
@@ -6245,7 +6343,7 @@ const captureKuaishouEncodeStack = () => {
|
|
|
6245
6343
|
* @returns 用于 `SECS.s` 的栈尾字符串
|
|
6246
6344
|
*/
|
|
6247
6345
|
const deriveKuaishouSecsStackTail = (stack = captureKuaishouEncodeStack()) => {
|
|
6248
|
-
return stack.length > KUAISHOU_SECS_STACK_LIMIT ? stack.slice(-
|
|
6346
|
+
return stack.length > KUAISHOU_SECS_STACK_LIMIT ? stack.slice(-100) : stack;
|
|
6249
6347
|
};
|
|
6250
6348
|
/**
|
|
6251
6349
|
* 构造快手 `window.SECS` 的纯算法等价状态。
|
|
@@ -6277,7 +6375,6 @@ const getKuaishouPureRuntimeState = () => {
|
|
|
6277
6375
|
};
|
|
6278
6376
|
return pureRuntimeState;
|
|
6279
6377
|
};
|
|
6280
|
-
|
|
6281
6378
|
//#endregion
|
|
6282
6379
|
//#region src/platform/kuaishou/sign/index.ts
|
|
6283
6380
|
/**
|
|
@@ -6370,7 +6467,6 @@ var kuaishouSign = class {
|
|
|
6370
6467
|
return this.signLiveApiUrl(request.url, cookie, request.signPath);
|
|
6371
6468
|
}
|
|
6372
6469
|
};
|
|
6373
|
-
|
|
6374
6470
|
//#endregion
|
|
6375
6471
|
//#region src/platform/kuaishou/getdata.ts
|
|
6376
6472
|
/**
|
|
@@ -6930,7 +7026,7 @@ const dedupeLiveRoomPlayList = (items) => {
|
|
|
6930
7026
|
* @param requestConfig - 外部请求配置(优先级最高)
|
|
6931
7027
|
* @returns 返回快手数据;当前 user/live 能力已优先走纯协议聚合链路
|
|
6932
7028
|
*/
|
|
6933
|
-
const KuaishouData = async (data
|
|
7029
|
+
const KuaishouData = async (data, cookie, requestConfig) => {
|
|
6934
7030
|
const defHeaders = getKuaishouDefaultConfig(cookie)["headers"];
|
|
6935
7031
|
const baseRequestConfig = {
|
|
6936
7032
|
method: "POST",
|
|
@@ -6968,27 +7064,27 @@ const KuaishouData = async (data$1, cookie, requestConfig) => {
|
|
|
6968
7064
|
const fetchKuaishouLiveApiPayload = (type, request, refererPath, config) => {
|
|
6969
7065
|
return GlobalGetData$2(type, buildLiveApiRequestConfig(request, refererPath, cookie, requestConfig), config);
|
|
6970
7066
|
};
|
|
6971
|
-
switch (data
|
|
6972
|
-
case "videoWork": return fetchKuaishouGraphqlPayload(data
|
|
6973
|
-
case "comments": return fetchKuaishouGraphqlPayload(data
|
|
7067
|
+
switch (data.methodType) {
|
|
7068
|
+
case "videoWork": return fetchKuaishouGraphqlPayload(data.methodType, kuaishouApiUrls.videoWork({ photoId: data.photoId }));
|
|
7069
|
+
case "comments": return fetchKuaishouGraphqlPayload(data.methodType, kuaishouApiUrls.comments({ photoId: data.photoId }));
|
|
6974
7070
|
case "userProfile": {
|
|
6975
|
-
const refererPath = `profile/${encodeURIComponent(data
|
|
7071
|
+
const refererPath = `profile/${encodeURIComponent(data.principalId)}`;
|
|
6976
7072
|
const [userInfoPayload, sensitivePayload, publicPayload, privatePayload, likedPayload, playbackPayload, interestListPayload, interestMaskPayload, categoryConfigPayload, categoryDataPayload, categoryClassifyPayload, liveDetailPayload] = await Promise.all([
|
|
6977
|
-
fetchKuaishouLiveApiPayload(data
|
|
6978
|
-
fetchKuaishouLiveApiPayload(data
|
|
6979
|
-
fetchKuaishouLiveApiPayload(data
|
|
6980
|
-
fetchKuaishouLiveApiPayload(data
|
|
6981
|
-
fetchKuaishouLiveApiPayload(data
|
|
6982
|
-
fetchKuaishouLiveApiPayload(data
|
|
6983
|
-
fetchKuaishouLiveApiPayload(data
|
|
6984
|
-
fetchKuaishouLiveApiPayload(data
|
|
6985
|
-
fetchKuaishouLiveApiPayload(data
|
|
6986
|
-
fetchKuaishouLiveApiPayload(data
|
|
6987
|
-
fetchKuaishouLiveApiPayload(data
|
|
6988
|
-
fetchKuaishouLiveApiPayload(data
|
|
7073
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.userInfoById({ principalId: data.principalId }), refererPath),
|
|
7074
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.userSensitiveInfo({ principalId: data.principalId }), refererPath, { allowResult2: true }),
|
|
7075
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.profilePublic({ principalId: data.principalId }), refererPath, { allowResult2: true }),
|
|
7076
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.profilePrivate({ principalId: data.principalId }), refererPath, { allowResult2: true }),
|
|
7077
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.profileLiked({ principalId: data.principalId }), refererPath, { allowResult2: true }),
|
|
7078
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.playbackList({ principalId: data.principalId }), refererPath, { allowResult2: true }),
|
|
7079
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.profileInterestList({ principalId: data.principalId }), refererPath, { allowResult2: true }),
|
|
7080
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.interestMaskList(), refererPath, { allowResult2: true }),
|
|
7081
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.categoryConfig(), refererPath),
|
|
7082
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.categoryData(), refererPath),
|
|
7083
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.categoryClassify(), refererPath),
|
|
7084
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.liveDetail({ principalId: data.principalId }), refererPath, { allowResult2: true })
|
|
6989
7085
|
]);
|
|
6990
7086
|
if (isErrorDetailLike(userInfoPayload)) return userInfoPayload;
|
|
6991
|
-
const userProfile = createEmptyUserProfileResult(data
|
|
7087
|
+
const userProfile = createEmptyUserProfileResult(data.principalId);
|
|
6992
7088
|
const userInfo = userInfoPayload?.data?.userInfo;
|
|
6993
7089
|
const sensitiveInfo = isErrorDetailLike(sensitivePayload) ? null : sensitivePayload?.data?.sensitiveUserInfo ?? null;
|
|
6994
7090
|
const liveDetailData = resolveKuaishouLiveDetailData(liveDetailPayload);
|
|
@@ -7002,10 +7098,10 @@ const KuaishouData = async (data$1, cookie, requestConfig) => {
|
|
|
7002
7098
|
const nextInterestMask = !isErrorDetailLike(interestMaskPayload) && Array.isArray(interestMaskPayload?.data) ? interestMaskPayload.data : userProfile.interestMask;
|
|
7003
7099
|
return {
|
|
7004
7100
|
...userProfile,
|
|
7005
|
-
principalId: data
|
|
7101
|
+
principalId: data.principalId,
|
|
7006
7102
|
author: {
|
|
7007
7103
|
...userProfile.author,
|
|
7008
|
-
principalId: data
|
|
7104
|
+
principalId: data.principalId,
|
|
7009
7105
|
userInfo: normalizedAuthor,
|
|
7010
7106
|
sensitiveInfo,
|
|
7011
7107
|
followInfo: {},
|
|
@@ -7036,25 +7132,25 @@ const KuaishouData = async (data$1, cookie, requestConfig) => {
|
|
|
7036
7132
|
};
|
|
7037
7133
|
}
|
|
7038
7134
|
case "userWorkList": {
|
|
7039
|
-
const refererPath = `profile/${encodeURIComponent(data
|
|
7040
|
-
const publicPayload = await fetchKuaishouLiveApiPayload(data
|
|
7041
|
-
principalId: data
|
|
7042
|
-
pcursor: data
|
|
7043
|
-
count: data
|
|
7135
|
+
const refererPath = `profile/${encodeURIComponent(data.principalId)}`;
|
|
7136
|
+
const publicPayload = await fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.userWorkList({
|
|
7137
|
+
principalId: data.principalId,
|
|
7138
|
+
pcursor: data.pcursor,
|
|
7139
|
+
count: data.count
|
|
7044
7140
|
}), refererPath, { allowResult2: true });
|
|
7045
7141
|
if (isErrorDetailLike(publicPayload)) return publicPayload;
|
|
7046
|
-
return resolveKuaishouUserWorkList(data
|
|
7142
|
+
return resolveKuaishouUserWorkList(data.principalId, publicPayload);
|
|
7047
7143
|
}
|
|
7048
7144
|
case "liveRoomInfo": {
|
|
7049
|
-
const refererPath = `u/${encodeURIComponent(data
|
|
7145
|
+
const refererPath = `u/${encodeURIComponent(data.principalId)}`;
|
|
7050
7146
|
const [liveDetailPayload, userInfoPayload, sensitivePayload, emojiPayload] = await Promise.all([
|
|
7051
|
-
fetchKuaishouLiveApiPayload(data
|
|
7052
|
-
fetchKuaishouLiveApiPayload(data
|
|
7053
|
-
fetchKuaishouLiveApiPayload(data
|
|
7054
|
-
fetchKuaishouGraphqlPayload(data
|
|
7147
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.liveDetail({ principalId: data.principalId }), refererPath, { allowResult2: true }),
|
|
7148
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.userInfoById({ principalId: data.principalId }), refererPath, { allowResult2: true }),
|
|
7149
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.userSensitiveInfo({ principalId: data.principalId }), refererPath, { allowResult2: true }),
|
|
7150
|
+
fetchKuaishouGraphqlPayload(data.methodType, kuaishouApiUrls.emojiList(), { allowResult2: true })
|
|
7055
7151
|
]);
|
|
7056
7152
|
if (isErrorDetailLike(liveDetailPayload)) return liveDetailPayload;
|
|
7057
|
-
const liveRoomInfo = createEmptyLiveRoomInfoResult(data
|
|
7153
|
+
const liveRoomInfo = createEmptyLiveRoomInfoResult(data.principalId);
|
|
7058
7154
|
const liveDetailData = resolveKuaishouLiveDetailData(liveDetailPayload);
|
|
7059
7155
|
if (!liveDetailData) return liveRoomInfo;
|
|
7060
7156
|
const userInfo = isErrorDetailLike(userInfoPayload) ? void 0 : userInfoPayload?.data?.userInfo;
|
|
@@ -7072,15 +7168,15 @@ const KuaishouData = async (data$1, cookie, requestConfig) => {
|
|
|
7072
7168
|
const shouldFetchWebsocketInfo = liveDetailWebsocketMeta.websocketUrls.length === 0 || !liveDetailWebsocketMeta.token;
|
|
7073
7169
|
const shouldFetchRecommendList = liveDetailRecommendList.length === 0;
|
|
7074
7170
|
const [giftPayload, websocketPayload, recoPayload] = await Promise.all([
|
|
7075
|
-
fetchKuaishouLiveApiPayload(data
|
|
7076
|
-
shouldFetchWebsocketInfo ? fetchKuaishouLiveApiPayload(data
|
|
7077
|
-
shouldFetchRecommendList ? fetchKuaishouLiveApiPayload(data
|
|
7171
|
+
fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.liveGiftList(liveStreamId), refererPath, { allowResult2: true }),
|
|
7172
|
+
shouldFetchWebsocketInfo ? fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.liveWebsocketInfo(liveStreamId), refererPath, { allowResult2: true }) : Promise.resolve(null),
|
|
7173
|
+
shouldFetchRecommendList ? fetchKuaishouLiveApiPayload(data.methodType, kuaishouApiUrls.liveReco(currentGameId), refererPath, { allowResult2: true }) : Promise.resolve(null)
|
|
7078
7174
|
]);
|
|
7079
7175
|
const resolvedRecommendList = !isErrorDetailLike(recoPayload) && Array.isArray(recoPayload?.data?.list) ? recoPayload.data.list : liveDetailRecommendList;
|
|
7080
7176
|
const nextPlayList = dedupeLiveRoomPlayList([currentLiveRoomItem, ...Array.isArray(resolvedRecommendList) ? resolvedRecommendList.map((item) => mapRecoItemToLiveRoomPlayItem(item)) : []]);
|
|
7081
7177
|
return {
|
|
7082
7178
|
...liveRoomInfo,
|
|
7083
|
-
principalId: data
|
|
7179
|
+
principalId: data.principalId,
|
|
7084
7180
|
activeIndex: 0,
|
|
7085
7181
|
current: currentLiveRoomItem,
|
|
7086
7182
|
playList: nextPlayList,
|
|
@@ -7098,9 +7194,9 @@ const KuaishouData = async (data$1, cookie, requestConfig) => {
|
|
|
7098
7194
|
}
|
|
7099
7195
|
};
|
|
7100
7196
|
}
|
|
7101
|
-
case "emojiList": return fetchKuaishouGraphqlPayload(data
|
|
7197
|
+
case "emojiList": return fetchKuaishouGraphqlPayload(data.methodType, kuaishouApiUrls.emojiList());
|
|
7102
7198
|
default:
|
|
7103
|
-
|
|
7199
|
+
emitLogWarn(`Unknown Kuaishou API method: "${data.methodType}"`);
|
|
7104
7200
|
return null;
|
|
7105
7201
|
}
|
|
7106
7202
|
};
|
|
@@ -7139,15 +7235,15 @@ const GlobalGetData$2 = async (type, options, config) => {
|
|
|
7139
7235
|
requestBody: JSON.stringify(options.data)
|
|
7140
7236
|
};
|
|
7141
7237
|
warningMessage = `
|
|
7142
|
-
|
|
7238
|
+
获取响应数据失败!原因:接口返回内容为空,你的快手ck可能已经失效!
|
|
7143
7239
|
请求类型:「${type}」
|
|
7144
7240
|
请求URL:${options.url}
|
|
7145
7241
|
请求参数:${JSON.stringify(options.data, null, 2)}
|
|
7146
7242
|
`;
|
|
7147
|
-
|
|
7243
|
+
emitLogWarn(warningMessage);
|
|
7148
7244
|
const cookieError = new Error(Err.errorDescription);
|
|
7149
7245
|
Object.assign(cookieError, {
|
|
7150
|
-
code:
|
|
7246
|
+
code: "INVALID_COOKIE",
|
|
7151
7247
|
data: result,
|
|
7152
7248
|
amagiError: Err
|
|
7153
7249
|
});
|
|
@@ -7160,7 +7256,7 @@ const GlobalGetData$2 = async (type, options, config) => {
|
|
|
7160
7256
|
amagiMessage: warningMessage
|
|
7161
7257
|
};
|
|
7162
7258
|
return {
|
|
7163
|
-
code:
|
|
7259
|
+
code: "UNKNOWN_ERROR",
|
|
7164
7260
|
data: null,
|
|
7165
7261
|
amagiError: {
|
|
7166
7262
|
errorDescription: "未知错误",
|
|
@@ -7171,7 +7267,6 @@ const GlobalGetData$2 = async (type, options, config) => {
|
|
|
7171
7267
|
};
|
|
7172
7268
|
}
|
|
7173
7269
|
};
|
|
7174
|
-
|
|
7175
7270
|
//#endregion
|
|
7176
7271
|
//#region src/model/fetchers/kuaishou/internal.ts
|
|
7177
7272
|
/**
|
|
@@ -7223,7 +7318,6 @@ async function fetchKuaishouInternal(methodType, options, config) {
|
|
|
7223
7318
|
throw new Error(`快手数据获取失败: ${errorMessage}`);
|
|
7224
7319
|
}
|
|
7225
7320
|
}
|
|
7226
|
-
|
|
7227
7321
|
//#endregion
|
|
7228
7322
|
//#region src/model/fetchers/kuaishou/api.ts
|
|
7229
7323
|
/**
|
|
@@ -7328,7 +7422,6 @@ async function fetchEmojiList$1(options, cookie, requestConfig) {
|
|
|
7328
7422
|
requestConfig
|
|
7329
7423
|
});
|
|
7330
7424
|
}
|
|
7331
|
-
|
|
7332
7425
|
//#endregion
|
|
7333
7426
|
//#region src/model/fetchers/kuaishou/index.ts
|
|
7334
7427
|
/**
|
|
@@ -7372,7 +7465,6 @@ function createBoundKuaishouFetcher(cookie, requestConfig) {
|
|
|
7372
7465
|
fetchEmojiList: (options, reqConfig) => fetchEmojiList$1(options, cookie, reqConfig ?? requestConfig)
|
|
7373
7466
|
};
|
|
7374
7467
|
}
|
|
7375
|
-
|
|
7376
7468
|
//#endregion
|
|
7377
7469
|
//#region src/platform/xiaohongshu/getdata.ts
|
|
7378
7470
|
/**
|
|
@@ -7382,133 +7474,137 @@ function createBoundKuaishouFetcher(cookie, requestConfig) {
|
|
|
7382
7474
|
* @param requestConfig - 外部请求配置
|
|
7383
7475
|
* @returns 返回小红书数据
|
|
7384
7476
|
*/
|
|
7385
|
-
const XiaohongshuData = async (data
|
|
7386
|
-
|
|
7387
|
-
const
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
...
|
|
7393
|
-
...requestConfig?.headers ?? {}
|
|
7394
|
-
}
|
|
7395
|
-
};
|
|
7396
|
-
const xiaohongshuApiUrls$1 = createXiaohongshuApiUrls();
|
|
7397
|
-
switch (data$1.methodType) {
|
|
7398
|
-
case "homeFeed": return await GlobalGetData$1(data$1.methodType, {
|
|
7399
|
-
...baseRequestConfig,
|
|
7400
|
-
url: xiaohongshuApiUrls$1.homeFeed(data$1).Url,
|
|
7401
|
-
data: JSON.stringify(xiaohongshuApiUrls$1.homeFeed(data$1).Body),
|
|
7402
|
-
headers: {
|
|
7403
|
-
...baseRequestConfig.headers,
|
|
7404
|
-
"x-s": xiaohongshuSign.generateXSPost(xiaohongshuApiUrls$1.homeFeed(data$1).apiPath, xiaohongshuSign.extractA1FromCookie(cookie ?? ""), "xhs-pc-web", xiaohongshuApiUrls$1.homeFeed(data$1).Body),
|
|
7405
|
-
"x-s-common": xiaohongshuSign.generateXSCommon(cookie ?? ""),
|
|
7406
|
-
"x-t": xiaohongshuSign.generateXT()
|
|
7407
|
-
}
|
|
7408
|
-
});
|
|
7409
|
-
case "noteDetail": return await GlobalGetData$1(data$1.methodType, {
|
|
7410
|
-
...baseRequestConfig,
|
|
7411
|
-
url: xiaohongshuApiUrls$1.noteDetail(data$1).Url,
|
|
7412
|
-
data: xiaohongshuApiUrls$1.noteDetail(data$1).Body,
|
|
7477
|
+
const XiaohongshuData = async (data, cookie, requestConfig) => {
|
|
7478
|
+
/** 使用指定 Cookie 构建一次完整的小红书 API 请求。 */
|
|
7479
|
+
const requestWithCookie = async (requestCookie) => {
|
|
7480
|
+
const defHeaders = getXiaohongshuDefaultConfig(requestCookie)["headers"];
|
|
7481
|
+
const baseRequestConfig = {
|
|
7482
|
+
method: "POST",
|
|
7483
|
+
timeout: 1e4,
|
|
7484
|
+
...requestConfig,
|
|
7413
7485
|
headers: {
|
|
7414
|
-
...
|
|
7415
|
-
|
|
7416
|
-
"x-s-common": xiaohongshuSign.generateXSCommon(cookie ?? ""),
|
|
7417
|
-
"x-t": xiaohongshuSign.generateXT()
|
|
7486
|
+
...defHeaders,
|
|
7487
|
+
...requestConfig?.headers ?? {}
|
|
7418
7488
|
}
|
|
7419
|
-
}
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
...defHeaders,
|
|
7427
|
-
...requestConfig?.headers ?? {}
|
|
7428
|
-
}
|
|
7429
|
-
};
|
|
7430
|
-
return await GlobalGetData$1(data$1.methodType, {
|
|
7431
|
-
...baseRequestConfig$1,
|
|
7432
|
-
url: xiaohongshuApiUrls$1.noteComments(data$1).Url,
|
|
7489
|
+
};
|
|
7490
|
+
const xiaohongshuApiUrls = createXiaohongshuApiUrls();
|
|
7491
|
+
switch (data.methodType) {
|
|
7492
|
+
case "homeFeed": return await GlobalGetData$1(data.methodType, {
|
|
7493
|
+
...baseRequestConfig,
|
|
7494
|
+
url: xiaohongshuApiUrls.homeFeed(data).Url,
|
|
7495
|
+
data: JSON.stringify(xiaohongshuApiUrls.homeFeed(data).Body),
|
|
7433
7496
|
headers: {
|
|
7434
|
-
...baseRequestConfig
|
|
7435
|
-
"x-s": xiaohongshuSign.
|
|
7436
|
-
"x-s-common": xiaohongshuSign.generateXSCommon(
|
|
7497
|
+
...baseRequestConfig.headers,
|
|
7498
|
+
"x-s": xiaohongshuSign.generateXSPost(xiaohongshuApiUrls.homeFeed(data).apiPath, xiaohongshuSign.extractA1FromCookie(requestCookie), "xhs-pc-web", xiaohongshuApiUrls.homeFeed(data).Body),
|
|
7499
|
+
"x-s-common": xiaohongshuSign.generateXSCommon(requestCookie),
|
|
7437
7500
|
"x-t": xiaohongshuSign.generateXT()
|
|
7438
7501
|
}
|
|
7439
7502
|
});
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
timeout: 1e4,
|
|
7445
|
-
...requestConfig,
|
|
7503
|
+
case "noteDetail": return await GlobalGetData$1(data.methodType, {
|
|
7504
|
+
...baseRequestConfig,
|
|
7505
|
+
url: xiaohongshuApiUrls.noteDetail(data).Url,
|
|
7506
|
+
data: xiaohongshuApiUrls.noteDetail(data).Body,
|
|
7446
7507
|
headers: {
|
|
7447
|
-
...
|
|
7448
|
-
|
|
7508
|
+
...baseRequestConfig.headers,
|
|
7509
|
+
"x-s": xiaohongshuSign.generateXSPost(xiaohongshuApiUrls.noteDetail(data).apiPath, xiaohongshuSign.extractA1FromCookie(requestCookie), "xhs-pc-web", xiaohongshuApiUrls.noteDetail(data).Body),
|
|
7510
|
+
"x-s-common": xiaohongshuSign.generateXSCommon(requestCookie),
|
|
7511
|
+
"x-t": xiaohongshuSign.generateXT()
|
|
7449
7512
|
}
|
|
7450
|
-
};
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7513
|
+
});
|
|
7514
|
+
case "noteComments": {
|
|
7515
|
+
const baseRequestConfig = {
|
|
7516
|
+
method: "GET",
|
|
7517
|
+
timeout: 1e4,
|
|
7518
|
+
...requestConfig,
|
|
7519
|
+
headers: {
|
|
7520
|
+
...defHeaders,
|
|
7521
|
+
...requestConfig?.headers ?? {}
|
|
7522
|
+
}
|
|
7523
|
+
};
|
|
7524
|
+
return await GlobalGetData$1(data.methodType, {
|
|
7525
|
+
...baseRequestConfig,
|
|
7526
|
+
url: xiaohongshuApiUrls.noteComments(data).Url,
|
|
7456
7527
|
headers: {
|
|
7457
|
-
...baseRequestConfig
|
|
7458
|
-
"x-s": xiaohongshuSign.generateXSGet(xiaohongshuApiUrls
|
|
7459
|
-
"x-s-common": xiaohongshuSign.generateXSCommon(
|
|
7528
|
+
...baseRequestConfig.headers,
|
|
7529
|
+
"x-s": xiaohongshuSign.generateXSGet(xiaohongshuApiUrls.noteComments(data).apiPath, xiaohongshuSign.extractA1FromCookie(requestCookie), "xhs-pc-web"),
|
|
7530
|
+
"x-s-common": xiaohongshuSign.generateXSCommon(requestCookie),
|
|
7460
7531
|
"x-t": xiaohongshuSign.generateXT()
|
|
7461
7532
|
}
|
|
7462
|
-
})
|
|
7463
|
-
msg: "success"
|
|
7464
|
-
};
|
|
7465
|
-
}
|
|
7466
|
-
case "userNoteList": return await GlobalGetData$1(data$1.methodType, {
|
|
7467
|
-
...baseRequestConfig,
|
|
7468
|
-
method: "GET",
|
|
7469
|
-
url: xiaohongshuApiUrls$1.userNoteList(data$1).Url,
|
|
7470
|
-
headers: {
|
|
7471
|
-
...baseRequestConfig.headers,
|
|
7472
|
-
"x-b3-traceid": xiaohongshuSign.generateXB3Traceid(),
|
|
7473
|
-
"x-s": xiaohongshuSign.generateXSGet(xiaohongshuApiUrls$1.userNoteList(data$1).apiPath, xiaohongshuSign.extractA1FromCookie(cookie ?? ""), "xhs-pc-web"),
|
|
7474
|
-
"x-s-common": xiaohongshuSign.generateXSCommon(cookie ?? ""),
|
|
7475
|
-
"x-t": xiaohongshuSign.generateXT()
|
|
7533
|
+
});
|
|
7476
7534
|
}
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7535
|
+
case "userProfile": {
|
|
7536
|
+
const baseRequestConfig = {
|
|
7537
|
+
method: "GET",
|
|
7538
|
+
timeout: 1e4,
|
|
7539
|
+
...requestConfig,
|
|
7540
|
+
headers: {
|
|
7541
|
+
...defHeaders,
|
|
7542
|
+
...requestConfig?.headers ?? {}
|
|
7543
|
+
}
|
|
7544
|
+
};
|
|
7545
|
+
return {
|
|
7546
|
+
code: 0,
|
|
7547
|
+
data: extractCreatorInfoFromHtml(await GlobalGetData$1(data.methodType, {
|
|
7548
|
+
...baseRequestConfig,
|
|
7549
|
+
url: xiaohongshuApiUrls.userProfile(data).Url,
|
|
7550
|
+
headers: {
|
|
7551
|
+
...baseRequestConfig.headers,
|
|
7552
|
+
"x-s": xiaohongshuSign.generateXSGet(xiaohongshuApiUrls.userProfile(data).apiPath, xiaohongshuSign.extractA1FromCookie(requestCookie), "xhs-pc-web"),
|
|
7553
|
+
"x-s-common": xiaohongshuSign.generateXSCommon(requestCookie),
|
|
7554
|
+
"x-t": xiaohongshuSign.generateXT()
|
|
7555
|
+
}
|
|
7556
|
+
})),
|
|
7557
|
+
msg: "success"
|
|
7558
|
+
};
|
|
7559
|
+
}
|
|
7560
|
+
case "userNoteList": return await GlobalGetData$1(data.methodType, {
|
|
7561
|
+
...baseRequestConfig,
|
|
7480
7562
|
method: "GET",
|
|
7481
|
-
|
|
7482
|
-
...requestConfig,
|
|
7563
|
+
url: xiaohongshuApiUrls.userNoteList(data).Url,
|
|
7483
7564
|
headers: {
|
|
7484
|
-
...
|
|
7485
|
-
|
|
7565
|
+
...baseRequestConfig.headers,
|
|
7566
|
+
"x-b3-traceid": xiaohongshuSign.generateXB3Traceid(),
|
|
7567
|
+
"x-s": xiaohongshuSign.generateXSGet(xiaohongshuApiUrls.userNoteList(data).apiPath, xiaohongshuSign.extractA1FromCookie(requestCookie), "xhs-pc-web"),
|
|
7568
|
+
"x-s-common": xiaohongshuSign.generateXSCommon(requestCookie),
|
|
7569
|
+
"x-t": xiaohongshuSign.generateXT()
|
|
7486
7570
|
}
|
|
7487
|
-
};
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7571
|
+
});
|
|
7572
|
+
case "emojiList": {
|
|
7573
|
+
const baseRequestConfig = {
|
|
7574
|
+
method: "GET",
|
|
7575
|
+
timeout: 1e4,
|
|
7576
|
+
...requestConfig,
|
|
7577
|
+
headers: {
|
|
7578
|
+
...defHeaders,
|
|
7579
|
+
...requestConfig?.headers ?? {}
|
|
7580
|
+
}
|
|
7581
|
+
};
|
|
7582
|
+
return await GlobalGetData$1(data.methodType, {
|
|
7583
|
+
...baseRequestConfig,
|
|
7584
|
+
url: xiaohongshuApiUrls.emojiList(data).Url,
|
|
7585
|
+
headers: {
|
|
7586
|
+
...baseRequestConfig.headers,
|
|
7587
|
+
"x-s": xiaohongshuSign.generateXSGet(xiaohongshuApiUrls.emojiList(data).apiPath, xiaohongshuSign.extractA1FromCookie(requestCookie), "xhs-pc-web"),
|
|
7588
|
+
"x-s-common": xiaohongshuSign.generateXSCommon(requestCookie),
|
|
7589
|
+
"x-t": xiaohongshuSign.generateXT()
|
|
7590
|
+
}
|
|
7591
|
+
});
|
|
7592
|
+
}
|
|
7593
|
+
case "searchNotes": return await GlobalGetData$1(data.methodType, {
|
|
7594
|
+
...baseRequestConfig,
|
|
7595
|
+
url: xiaohongshuApiUrls.searchNotes(data).Url,
|
|
7596
|
+
data: xiaohongshuApiUrls.searchNotes(data).Body,
|
|
7491
7597
|
headers: {
|
|
7492
|
-
...baseRequestConfig
|
|
7493
|
-
"x-s": xiaohongshuSign.
|
|
7494
|
-
"x-s-common": xiaohongshuSign.generateXSCommon(
|
|
7598
|
+
...baseRequestConfig.headers,
|
|
7599
|
+
"x-s": xiaohongshuSign.generateXSPost(xiaohongshuApiUrls.searchNotes(data).apiPath, xiaohongshuSign.extractA1FromCookie(requestCookie), "xhs-pc-web"),
|
|
7600
|
+
"x-s-common": xiaohongshuSign.generateXSCommon(requestCookie),
|
|
7495
7601
|
"x-t": xiaohongshuSign.generateXT()
|
|
7496
7602
|
}
|
|
7497
7603
|
});
|
|
7604
|
+
default: throw new Error(`Unknown Xiaohongshu API method: "${data.methodType}"`);
|
|
7498
7605
|
}
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
url: xiaohongshuApiUrls$1.searchNotes(data$1).Url,
|
|
7502
|
-
data: xiaohongshuApiUrls$1.searchNotes(data$1).Body,
|
|
7503
|
-
headers: {
|
|
7504
|
-
...baseRequestConfig.headers,
|
|
7505
|
-
"x-s": xiaohongshuSign.generateXSPost(xiaohongshuApiUrls$1.searchNotes(data$1).apiPath, xiaohongshuSign.extractA1FromCookie(cookie ?? ""), "xhs-pc-web"),
|
|
7506
|
-
"x-s-common": xiaohongshuSign.generateXSCommon(cookie ?? ""),
|
|
7507
|
-
"x-t": xiaohongshuSign.generateXT()
|
|
7508
|
-
}
|
|
7509
|
-
});
|
|
7510
|
-
default: throw new Error(`Unknown Xiaohongshu API method: "${logger.red(data$1.methodType)}"`);
|
|
7511
|
-
}
|
|
7606
|
+
};
|
|
7607
|
+
return requestWithCookie(cookie?.trim() ?? "");
|
|
7512
7608
|
};
|
|
7513
7609
|
/**
|
|
7514
7610
|
* 全局数据获取函数
|
|
@@ -7532,7 +7628,7 @@ const GlobalGetData$1 = async (methodType, config) => {
|
|
|
7532
7628
|
if (response.code !== 0) throw new Error(`API request failed: ${response.data?.msg ?? response.msg ?? "Unknown error"}, code: ${response.code}`);
|
|
7533
7629
|
return response;
|
|
7534
7630
|
} catch (error) {
|
|
7535
|
-
|
|
7631
|
+
emitLogError(`Xiaohongshu API request failed [${methodType}]:`, error.message);
|
|
7536
7632
|
return {
|
|
7537
7633
|
code: 500,
|
|
7538
7634
|
message: "error",
|
|
@@ -7546,7 +7642,6 @@ const GlobalGetData$1 = async (methodType, config) => {
|
|
|
7546
7642
|
};
|
|
7547
7643
|
}
|
|
7548
7644
|
};
|
|
7549
|
-
|
|
7550
7645
|
//#endregion
|
|
7551
7646
|
//#region src/model/fetchers/xiaohongshu/internal.ts
|
|
7552
7647
|
/**
|
|
@@ -7557,9 +7652,9 @@ const GlobalGetData$1 = async (methodType, config) => {
|
|
|
7557
7652
|
* 搜索排序类型映射
|
|
7558
7653
|
*/
|
|
7559
7654
|
const sortTypeMapping = {
|
|
7560
|
-
general:
|
|
7561
|
-
time_descending:
|
|
7562
|
-
popularity_descending:
|
|
7655
|
+
general: "general",
|
|
7656
|
+
time_descending: "time_descending",
|
|
7657
|
+
popularity_descending: "popularity_descending"
|
|
7563
7658
|
};
|
|
7564
7659
|
/**
|
|
7565
7660
|
* 小红书 API 内部调用函数
|
|
@@ -7606,7 +7701,6 @@ async function fetchXiaohongshuInternal(methodType, options, config) {
|
|
|
7606
7701
|
throw new Error(`小红书数据获取失败: ${errorMessage}`);
|
|
7607
7702
|
}
|
|
7608
7703
|
}
|
|
7609
|
-
|
|
7610
7704
|
//#endregion
|
|
7611
7705
|
//#region src/model/fetchers/xiaohongshu/misc.ts
|
|
7612
7706
|
/**
|
|
@@ -7628,7 +7722,6 @@ async function fetchEmojiList(options, cookie, requestConfig) {
|
|
|
7628
7722
|
requestConfig
|
|
7629
7723
|
});
|
|
7630
7724
|
}
|
|
7631
|
-
|
|
7632
7725
|
//#endregion
|
|
7633
7726
|
//#region src/model/fetchers/xiaohongshu/note.ts
|
|
7634
7727
|
/**
|
|
@@ -7695,7 +7788,6 @@ async function fetchNoteComments(options, cookie, requestConfig) {
|
|
|
7695
7788
|
requestConfig
|
|
7696
7789
|
});
|
|
7697
7790
|
}
|
|
7698
|
-
|
|
7699
7791
|
//#endregion
|
|
7700
7792
|
//#region src/model/fetchers/xiaohongshu/search.ts
|
|
7701
7793
|
/**
|
|
@@ -7730,7 +7822,6 @@ async function searchNotes(options, cookie, requestConfig) {
|
|
|
7730
7822
|
requestConfig
|
|
7731
7823
|
});
|
|
7732
7824
|
}
|
|
7733
|
-
|
|
7734
7825
|
//#endregion
|
|
7735
7826
|
//#region src/model/fetchers/xiaohongshu/user.ts
|
|
7736
7827
|
/**
|
|
@@ -7771,7 +7862,6 @@ async function fetchUserNoteList(options, cookie, requestConfig) {
|
|
|
7771
7862
|
requestConfig
|
|
7772
7863
|
});
|
|
7773
7864
|
}
|
|
7774
|
-
|
|
7775
7865
|
//#endregion
|
|
7776
7866
|
//#region src/model/fetchers/xiaohongshu/index.ts
|
|
7777
7867
|
/**
|
|
@@ -7821,7 +7911,6 @@ function createBoundXiaohongshuFetcher(cookie, requestConfig) {
|
|
|
7821
7911
|
fetchEmojiList: (options, reqConfig) => fetchEmojiList(options, cookie, reqConfig ?? requestConfig)
|
|
7822
7912
|
};
|
|
7823
7913
|
}
|
|
7824
|
-
|
|
7825
7914
|
//#endregion
|
|
7826
7915
|
//#region src/model/networks.ts
|
|
7827
7916
|
/** 可恢复的错误代码列表 */
|
|
@@ -7852,7 +7941,7 @@ const isRecoverableError = (error) => {
|
|
|
7852
7941
|
* 延迟函数
|
|
7853
7942
|
* @param ms - 延迟毫秒数
|
|
7854
7943
|
*/
|
|
7855
|
-
const delay = (ms) => new Promise((resolve
|
|
7944
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7856
7945
|
/**
|
|
7857
7946
|
* 创建网络错误响应
|
|
7858
7947
|
* @param error - 错误对象
|
|
@@ -7863,7 +7952,7 @@ const createNetworkErrorResult = (error, retries) => {
|
|
|
7863
7952
|
const errorCode = error.code ?? "UNKNOWN";
|
|
7864
7953
|
const message = `网络请求失败 [${errorCode}]: ${error.message} (已重试 ${retries} 次)`;
|
|
7865
7954
|
return createErrorResponse({
|
|
7866
|
-
code:
|
|
7955
|
+
code: "UNKNOWN_ERROR",
|
|
7867
7956
|
data: null,
|
|
7868
7957
|
amagiError: {
|
|
7869
7958
|
errorDescription: `${error.message} (已重试 ${retries} 次)`,
|
|
@@ -7880,7 +7969,7 @@ const createNetworkErrorResult = (error, retries) => {
|
|
|
7880
7969
|
* @returns 清理后的User-Agent字符串
|
|
7881
7970
|
*/
|
|
7882
7971
|
const cleanUserAgent = (userAgent) => {
|
|
7883
|
-
return userAgent.replace(/\s+Edg\/[\d
|
|
7972
|
+
return userAgent.replace(/\s+Edg\/[\d.]+/g, "");
|
|
7884
7973
|
};
|
|
7885
7974
|
/**
|
|
7886
7975
|
* 执行网络请求并返回数据(带自动重试)
|
|
@@ -8000,7 +8089,6 @@ const getHeadersAndData = async (config, maxRetries = DEFAULT_MAX_RETRIES) => {
|
|
|
8000
8089
|
data: response.data
|
|
8001
8090
|
};
|
|
8002
8091
|
};
|
|
8003
|
-
|
|
8004
8092
|
//#endregion
|
|
8005
8093
|
//#region src/model/logger.ts
|
|
8006
8094
|
/**
|
|
@@ -8101,7 +8189,6 @@ const logMiddleware = (pathsToLog) => {
|
|
|
8101
8189
|
next();
|
|
8102
8190
|
};
|
|
8103
8191
|
};
|
|
8104
|
-
|
|
8105
8192
|
//#endregion
|
|
8106
8193
|
//#region src/platform/bilibili/qtparam.ts
|
|
8107
8194
|
/**
|
|
@@ -8134,8 +8221,7 @@ const qtparam = async (BASEURL, cookie) => {
|
|
|
8134
8221
|
126,
|
|
8135
8222
|
127
|
|
8136
8223
|
];
|
|
8137
|
-
|
|
8138
|
-
logininfo.data.vipStatus === 1 ? isvip = true : isvip = false;
|
|
8224
|
+
const isvip = logininfo.data.vipStatus === 1;
|
|
8139
8225
|
if (isvip) return {
|
|
8140
8226
|
QUERY: `&fnval=4048&fourk=1&${sign}`,
|
|
8141
8227
|
STATUS: "isLogin",
|
|
@@ -8147,7 +8233,6 @@ const qtparam = async (BASEURL, cookie) => {
|
|
|
8147
8233
|
isvip
|
|
8148
8234
|
};
|
|
8149
8235
|
};
|
|
8150
|
-
|
|
8151
8236
|
//#endregion
|
|
8152
8237
|
//#region src/platform/bilibili/sign/bv2av.ts
|
|
8153
8238
|
const XOR_CODE = 23442827791579n;
|
|
@@ -8199,7 +8284,6 @@ const bv2av = (bvid) => {
|
|
|
8199
8284
|
const tmp = bvidArr.reduce((pre, bvidChar) => pre * BASE + BigInt(data.indexOf(bvidChar)), 0n);
|
|
8200
8285
|
return Number(tmp & MASK_CODE ^ XOR_CODE);
|
|
8201
8286
|
};
|
|
8202
|
-
|
|
8203
8287
|
//#endregion
|
|
8204
8288
|
//#region src/platform/bilibili/sign/danmaku_proto.ts
|
|
8205
8289
|
/**
|
|
@@ -8285,16 +8369,15 @@ function getProtoType() {
|
|
|
8285
8369
|
* @param data - 二进制 protobuf 数据
|
|
8286
8370
|
* @returns 解析后的弹幕数据
|
|
8287
8371
|
*/
|
|
8288
|
-
function parseDmSegMobileReply(data
|
|
8372
|
+
function parseDmSegMobileReply(data) {
|
|
8289
8373
|
const messageType = getProtoType();
|
|
8290
|
-
const buffer = data
|
|
8374
|
+
const buffer = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
8291
8375
|
const message = messageType.decode(buffer);
|
|
8292
8376
|
return messageType.toObject(message, {
|
|
8293
8377
|
longs: String,
|
|
8294
8378
|
defaults: true
|
|
8295
8379
|
});
|
|
8296
8380
|
}
|
|
8297
|
-
|
|
8298
8381
|
//#endregion
|
|
8299
8382
|
//#region src/platform/bilibili/sign/wbi.ts
|
|
8300
8383
|
/**
|
|
@@ -8417,7 +8500,6 @@ const wbi_sign = async (BASEURL, cookie) => {
|
|
|
8417
8500
|
for (const [key, value] of url.searchParams.entries()) params[key] = value;
|
|
8418
8501
|
return encWbi(params, web_keys.img_key, web_keys.sub_key);
|
|
8419
8502
|
};
|
|
8420
|
-
|
|
8421
8503
|
//#endregion
|
|
8422
8504
|
//#region src/platform/bilibili/getdata.ts
|
|
8423
8505
|
/**
|
|
@@ -8438,28 +8520,28 @@ const wbi_sign = async (BASEURL, cookie) => {
|
|
|
8438
8520
|
* @param requestConfig - 外部请求配置(优先级最高)
|
|
8439
8521
|
* @returns 返回B站数据
|
|
8440
8522
|
*/
|
|
8441
|
-
const fetchBilibili = async (data
|
|
8523
|
+
const fetchBilibili = async (data, cookie, requestConfig) => {
|
|
8442
8524
|
const baseRequestConfig = getBilibiliDefaultConfig(cookie, requestConfig);
|
|
8443
|
-
switch (data
|
|
8444
|
-
case "videoInfo": return await GlobalGetData(data
|
|
8525
|
+
switch (data.methodType) {
|
|
8526
|
+
case "videoInfo": return await GlobalGetData(data.methodType, {
|
|
8445
8527
|
...baseRequestConfig,
|
|
8446
|
-
url: bilibiliApiUrls.getVideoInfo({ bvid: data
|
|
8528
|
+
url: bilibiliApiUrls.getVideoInfo({ bvid: data.bvid })
|
|
8447
8529
|
});
|
|
8448
8530
|
case "videoStream": {
|
|
8449
8531
|
const sign = await qtparam(bilibiliApiUrls.getVideoStream({
|
|
8450
|
-
avid: data
|
|
8451
|
-
cid: data
|
|
8532
|
+
avid: data.avid,
|
|
8533
|
+
cid: data.cid
|
|
8452
8534
|
}), baseRequestConfig.headers?.Cookie);
|
|
8453
|
-
return await GlobalGetData(data
|
|
8535
|
+
return await GlobalGetData(data.methodType, {
|
|
8454
8536
|
...baseRequestConfig,
|
|
8455
8537
|
url: bilibiliApiUrls.getVideoStream({
|
|
8456
|
-
avid: data
|
|
8457
|
-
cid: data
|
|
8538
|
+
avid: data.avid,
|
|
8539
|
+
cid: data.cid
|
|
8458
8540
|
}) + sign.QUERY
|
|
8459
8541
|
});
|
|
8460
8542
|
}
|
|
8461
8543
|
case "comments": {
|
|
8462
|
-
let { oid, number, type, mode, pagination_str, plat, seek_rpid, web_location } = data
|
|
8544
|
+
let { oid, number, type, mode, pagination_str, plat, seek_rpid, web_location } = data;
|
|
8463
8545
|
let fetchedComments = [];
|
|
8464
8546
|
const maxRequestCount = 100;
|
|
8465
8547
|
let requestCount = 0;
|
|
@@ -8470,11 +8552,11 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
8470
8552
|
oid,
|
|
8471
8553
|
type
|
|
8472
8554
|
});
|
|
8473
|
-
if ((await GlobalGetData(data
|
|
8555
|
+
if ((await GlobalGetData(data.methodType, {
|
|
8474
8556
|
...baseRequestConfig,
|
|
8475
8557
|
url: checkStatusUrl
|
|
8476
8558
|
})).data === null) {
|
|
8477
|
-
|
|
8559
|
+
emitLogError("评论区未开放");
|
|
8478
8560
|
return {
|
|
8479
8561
|
code: 404,
|
|
8480
8562
|
message: "评论区未开放",
|
|
@@ -8492,7 +8574,7 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
8492
8574
|
web_location: web_location ?? "1315875"
|
|
8493
8575
|
});
|
|
8494
8576
|
const finalUrl = baseUrl + await wbi_sign(baseUrl, baseRequestConfig.headers?.cookie);
|
|
8495
|
-
const response = await GlobalGetData(data
|
|
8577
|
+
const response = await GlobalGetData(data.methodType, {
|
|
8496
8578
|
...baseRequestConfig,
|
|
8497
8579
|
url: finalUrl
|
|
8498
8580
|
});
|
|
@@ -8505,7 +8587,7 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
8505
8587
|
} else isEnd = true;
|
|
8506
8588
|
requestCount++;
|
|
8507
8589
|
if (isEnd || currentComments.length === 0 || !nextPaginationStr) {
|
|
8508
|
-
|
|
8590
|
+
emitLogInfo("已到达评论末尾或无更多评论");
|
|
8509
8591
|
break;
|
|
8510
8592
|
}
|
|
8511
8593
|
}
|
|
@@ -8513,43 +8595,43 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
8513
8595
|
...tmpresp,
|
|
8514
8596
|
data: {
|
|
8515
8597
|
...tmpresp.data,
|
|
8516
|
-
replies: Array.from(new Map(fetchedComments.map((item) => [item.rpid, item])).values()).slice(0, Number(data
|
|
8598
|
+
replies: Array.from(new Map(fetchedComments.map((item) => [item.rpid, item])).values()).slice(0, Number(data.number ?? 20))
|
|
8517
8599
|
}
|
|
8518
8600
|
};
|
|
8519
8601
|
}
|
|
8520
|
-
case "commentReplies": return await GlobalGetData(data
|
|
8602
|
+
case "commentReplies": return await GlobalGetData(data.methodType, {
|
|
8521
8603
|
...baseRequestConfig,
|
|
8522
|
-
url: bilibiliApiUrls.getCommentReplies(data
|
|
8604
|
+
url: bilibiliApiUrls.getCommentReplies(data)
|
|
8523
8605
|
});
|
|
8524
|
-
case "emojiList": return await GlobalGetData(data
|
|
8606
|
+
case "emojiList": return await GlobalGetData(data.methodType, {
|
|
8525
8607
|
...baseRequestConfig,
|
|
8526
8608
|
url: bilibiliApiUrls.getEmojiList()
|
|
8527
8609
|
});
|
|
8528
8610
|
case "bangumiInfo": {
|
|
8529
|
-
let id = data
|
|
8611
|
+
let id = data.ep_id ?? data.season_id;
|
|
8530
8612
|
if (!id) return false;
|
|
8531
8613
|
const idType = id ? id.startsWith("ep") ? "ep_id" : "season_id" : "ep_id";
|
|
8532
8614
|
const newId = idType === "ep_id" ? id.replace("ep", "") : id.replace("ss", "");
|
|
8533
|
-
return await GlobalGetData(data
|
|
8615
|
+
return await GlobalGetData(data.methodType, {
|
|
8534
8616
|
...baseRequestConfig,
|
|
8535
8617
|
url: bilibiliApiUrls.getBangumiInfo({ [idType]: newId })
|
|
8536
8618
|
});
|
|
8537
8619
|
}
|
|
8538
8620
|
case "bangumiStream": {
|
|
8539
8621
|
const sign = await qtparam(bilibiliApiUrls.getBangumiStream({
|
|
8540
|
-
cid: data
|
|
8541
|
-
ep_id: data
|
|
8622
|
+
cid: data.cid,
|
|
8623
|
+
ep_id: data.ep_id.replace("ep", "")
|
|
8542
8624
|
}), baseRequestConfig.headers?.cookie);
|
|
8543
|
-
return await GlobalGetData(data
|
|
8625
|
+
return await GlobalGetData(data.methodType, {
|
|
8544
8626
|
...baseRequestConfig,
|
|
8545
8627
|
url: bilibiliApiUrls.getBangumiStream({
|
|
8546
|
-
cid: data
|
|
8547
|
-
ep_id: data
|
|
8628
|
+
cid: data.cid,
|
|
8629
|
+
ep_id: data.ep_id.replace("ep", "")
|
|
8548
8630
|
}) + sign.QUERY
|
|
8549
8631
|
});
|
|
8550
8632
|
}
|
|
8551
8633
|
case "userDynamicList": {
|
|
8552
|
-
const { host_mid } = data
|
|
8634
|
+
const { host_mid } = data;
|
|
8553
8635
|
const hasExternalReferer = requestConfig?.headers && ("referer" in requestConfig.headers || "Referer" in requestConfig.headers);
|
|
8554
8636
|
const customHeaders = {
|
|
8555
8637
|
...baseRequestConfig.headers,
|
|
@@ -8557,7 +8639,7 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
8557
8639
|
...!hasExternalReferer && { Referer: `https://space.bilibili.com/${host_mid}/dynamic` }
|
|
8558
8640
|
};
|
|
8559
8641
|
const wbiSignQuery = await wbi_sign(bilibiliApiUrls.getUserDynamicList({ host_mid }), baseRequestConfig.headers?.cookie);
|
|
8560
|
-
return await GlobalGetData(data
|
|
8642
|
+
return await GlobalGetData(data.methodType, {
|
|
8561
8643
|
...baseRequestConfig,
|
|
8562
8644
|
headers: customHeaders,
|
|
8563
8645
|
url: bilibiliApiUrls.getUserDynamicList({ host_mid }) + wbiSignQuery
|
|
@@ -8569,55 +8651,48 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
8569
8651
|
...baseRequestConfig.headers,
|
|
8570
8652
|
...!hasExternalReferer && { Referer: void 0 }
|
|
8571
8653
|
};
|
|
8572
|
-
return await GlobalGetData(data
|
|
8573
|
-
...baseRequestConfig,
|
|
8574
|
-
headers: customHeaders,
|
|
8575
|
-
url: bilibiliApiUrls.getDynamicDetail({ dynamic_id: data$1.dynamic_id })
|
|
8576
|
-
});
|
|
8577
|
-
}
|
|
8578
|
-
case "dynamicCard": {
|
|
8579
|
-
const { dynamic_id } = data$1;
|
|
8580
|
-
const hasExternalReferer = requestConfig?.headers && "referer" in requestConfig.headers;
|
|
8581
|
-
const customHeaders = {
|
|
8582
|
-
...baseRequestConfig.headers,
|
|
8583
|
-
...!hasExternalReferer && { Referer: void 0 }
|
|
8584
|
-
};
|
|
8585
|
-
return await GlobalGetData(data$1.methodType, {
|
|
8654
|
+
return await GlobalGetData(data.methodType, {
|
|
8586
8655
|
...baseRequestConfig,
|
|
8587
8656
|
headers: customHeaders,
|
|
8588
|
-
url: bilibiliApiUrls.
|
|
8657
|
+
url: bilibiliApiUrls.getDynamicDetail({ dynamic_id: data.dynamic_id })
|
|
8589
8658
|
});
|
|
8590
8659
|
}
|
|
8660
|
+
case "dynamicCard": return {
|
|
8661
|
+
code: -404,
|
|
8662
|
+
message: "接口已停用:B站官方已于 `2025-08-09` 删除 dynamic_svr 接口,fetchDynamicCard 方法已废弃,调用讲返回错误信息",
|
|
8663
|
+
ttl: 1,
|
|
8664
|
+
data: null
|
|
8665
|
+
};
|
|
8591
8666
|
case "userCard": {
|
|
8592
|
-
const { host_mid } = data
|
|
8593
|
-
return await GlobalGetData(data
|
|
8667
|
+
const { host_mid } = data;
|
|
8668
|
+
return await GlobalGetData(data.methodType, {
|
|
8594
8669
|
...baseRequestConfig,
|
|
8595
8670
|
url: bilibiliApiUrls.getUserCard({ host_mid })
|
|
8596
8671
|
});
|
|
8597
8672
|
}
|
|
8598
8673
|
case "userSpaceInfo": {
|
|
8599
|
-
const wbiSignQuery = await wbi_sign(bilibiliApiUrls.getUserSpaceInfo({ host_mid: data
|
|
8600
|
-
return await GlobalGetData(data
|
|
8674
|
+
const wbiSignQuery = await wbi_sign(bilibiliApiUrls.getUserSpaceInfo({ host_mid: data.host_mid }), baseRequestConfig.headers?.cookie);
|
|
8675
|
+
return await GlobalGetData(data.methodType, {
|
|
8601
8676
|
...baseRequestConfig,
|
|
8602
|
-
url: bilibiliApiUrls.getUserSpaceInfo({ host_mid: data
|
|
8677
|
+
url: bilibiliApiUrls.getUserSpaceInfo({ host_mid: data.host_mid }) + wbiSignQuery
|
|
8603
8678
|
});
|
|
8604
8679
|
}
|
|
8605
|
-
case "liveRoomInfo": return await GlobalGetData(data
|
|
8680
|
+
case "liveRoomInfo": return await GlobalGetData(data.methodType, {
|
|
8606
8681
|
...baseRequestConfig,
|
|
8607
|
-
url: bilibiliApiUrls.getLiveRoomInfo({ room_id: data
|
|
8682
|
+
url: bilibiliApiUrls.getLiveRoomInfo({ room_id: data.room_id })
|
|
8608
8683
|
});
|
|
8609
|
-
case "liveRoomInit": return await GlobalGetData(data
|
|
8684
|
+
case "liveRoomInit": return await GlobalGetData(data.methodType, {
|
|
8610
8685
|
...baseRequestConfig,
|
|
8611
|
-
url: bilibiliApiUrls.getLiveRoomInit({ room_id: data
|
|
8686
|
+
url: bilibiliApiUrls.getLiveRoomInit({ room_id: data.room_id })
|
|
8612
8687
|
});
|
|
8613
|
-
case "loginQrcode": return await GlobalGetData(data
|
|
8688
|
+
case "loginQrcode": return await GlobalGetData(data.methodType, {
|
|
8614
8689
|
...baseRequestConfig,
|
|
8615
8690
|
url: bilibiliApiUrls.getLoginQrcode()
|
|
8616
8691
|
});
|
|
8617
8692
|
case "qrcodeStatus": try {
|
|
8618
8693
|
const result = await getHeadersAndData({
|
|
8619
8694
|
...baseRequestConfig,
|
|
8620
|
-
url: bilibiliApiUrls.getQrcodeStatus({ qrcode_key: data
|
|
8695
|
+
url: bilibiliApiUrls.getQrcodeStatus({ qrcode_key: data.qrcode_key })
|
|
8621
8696
|
});
|
|
8622
8697
|
if (isNetworkErrorResult(result)) {
|
|
8623
8698
|
const networkError = new Error(result.error.amagiError.errorDescription);
|
|
@@ -8626,7 +8701,7 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
8626
8701
|
data: null,
|
|
8627
8702
|
amagiError: {
|
|
8628
8703
|
...result.error.amagiError,
|
|
8629
|
-
requestType: data
|
|
8704
|
+
requestType: data.methodType
|
|
8630
8705
|
}
|
|
8631
8706
|
});
|
|
8632
8707
|
throw networkError;
|
|
@@ -8634,8 +8709,8 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
8634
8709
|
if (result.data.code !== 0) {
|
|
8635
8710
|
const Err = {
|
|
8636
8711
|
errorDescription: `获取响应数据失败!原因:${bilibiliErrorCodeMap[String(result.data.code)] || result.data.message || "未知错误"}!`,
|
|
8637
|
-
requestType: data
|
|
8638
|
-
requestUrl: bilibiliApiUrls.getQrcodeStatus({ qrcode_key: data
|
|
8712
|
+
requestType: data.methodType,
|
|
8713
|
+
requestUrl: bilibiliApiUrls.getQrcodeStatus({ qrcode_key: data.qrcode_key })
|
|
8639
8714
|
};
|
|
8640
8715
|
return {
|
|
8641
8716
|
code: result.data.code,
|
|
@@ -8654,65 +8729,65 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
8654
8729
|
} catch (error) {
|
|
8655
8730
|
if (error && typeof error === "object") return error;
|
|
8656
8731
|
return {
|
|
8657
|
-
code:
|
|
8732
|
+
code: "UNKNOWN_ERROR",
|
|
8658
8733
|
data: error.data,
|
|
8659
8734
|
amagiError: {
|
|
8660
8735
|
errorDescription: "未知错误",
|
|
8661
|
-
requestType: data
|
|
8662
|
-
requestUrl: bilibiliApiUrls.getQrcodeStatus({ qrcode_key: data
|
|
8736
|
+
requestType: data.methodType,
|
|
8737
|
+
requestUrl: bilibiliApiUrls.getQrcodeStatus({ qrcode_key: data.qrcode_key })
|
|
8663
8738
|
}
|
|
8664
8739
|
};
|
|
8665
8740
|
}
|
|
8666
|
-
case "loginStatus": return await GlobalGetData(data
|
|
8741
|
+
case "loginStatus": return await GlobalGetData(data.methodType, {
|
|
8667
8742
|
...baseRequestConfig,
|
|
8668
8743
|
url: bilibiliApiUrls.getLoginStatus()
|
|
8669
8744
|
});
|
|
8670
|
-
case "uploaderTotalViews": return await GlobalGetData(data
|
|
8745
|
+
case "uploaderTotalViews": return await GlobalGetData(data.methodType, {
|
|
8671
8746
|
...baseRequestConfig,
|
|
8672
|
-
url: bilibiliApiUrls.getUploaderTotalViews({ host_mid: data
|
|
8747
|
+
url: bilibiliApiUrls.getUploaderTotalViews({ host_mid: data.host_mid })
|
|
8673
8748
|
});
|
|
8674
8749
|
case "avToBv": return {
|
|
8675
8750
|
code: 0,
|
|
8676
8751
|
message: "success",
|
|
8677
|
-
data: { bvid: av2bv(Number(data
|
|
8752
|
+
data: { bvid: av2bv(Number(data.avid.toString().replace(/^av/i, ""))) }
|
|
8678
8753
|
};
|
|
8679
8754
|
case "bvToAv": return {
|
|
8680
8755
|
code: 0,
|
|
8681
8756
|
message: "success",
|
|
8682
|
-
data: { aid: "av" + bv2av(data
|
|
8757
|
+
data: { aid: "av" + bv2av(data.bvid) }
|
|
8683
8758
|
};
|
|
8684
|
-
case "articleContent": return await GlobalGetData(data
|
|
8759
|
+
case "articleContent": return await GlobalGetData(data.methodType, {
|
|
8685
8760
|
...baseRequestConfig,
|
|
8686
|
-
url: bilibiliApiUrls.getArticleContent({ id: data
|
|
8761
|
+
url: bilibiliApiUrls.getArticleContent({ id: data.id })
|
|
8687
8762
|
});
|
|
8688
|
-
case "articleCards": return await GlobalGetData(data
|
|
8763
|
+
case "articleCards": return await GlobalGetData(data.methodType, {
|
|
8689
8764
|
...baseRequestConfig,
|
|
8690
|
-
url: bilibiliApiUrls.getArticleCards({ ids: data
|
|
8765
|
+
url: bilibiliApiUrls.getArticleCards({ ids: data.ids })
|
|
8691
8766
|
});
|
|
8692
|
-
case "articleInfo": return await GlobalGetData(data
|
|
8767
|
+
case "articleInfo": return await GlobalGetData(data.methodType, {
|
|
8693
8768
|
...baseRequestConfig,
|
|
8694
|
-
url: bilibiliApiUrls.getArticleInfo({ id: data
|
|
8769
|
+
url: bilibiliApiUrls.getArticleInfo({ id: data.id })
|
|
8695
8770
|
});
|
|
8696
|
-
case "articleListInfo": return await GlobalGetData(data
|
|
8771
|
+
case "articleListInfo": return await GlobalGetData(data.methodType, {
|
|
8697
8772
|
...baseRequestConfig,
|
|
8698
|
-
url: bilibiliApiUrls.getArticleListInfo({ id: data
|
|
8773
|
+
url: bilibiliApiUrls.getArticleListInfo({ id: data.id })
|
|
8699
8774
|
});
|
|
8700
|
-
case "captchaFromVoucher": return await GlobalGetData(data
|
|
8775
|
+
case "captchaFromVoucher": return await GlobalGetData(data.methodType, {
|
|
8701
8776
|
...baseRequestConfig,
|
|
8702
8777
|
method: "POST",
|
|
8703
|
-
url: bilibiliApiUrls.getCaptchaFromVoucher(data
|
|
8704
|
-
data: bilibiliApiUrls.getCaptchaFromVoucher(data
|
|
8778
|
+
url: bilibiliApiUrls.getCaptchaFromVoucher(data).Url,
|
|
8779
|
+
data: bilibiliApiUrls.getCaptchaFromVoucher(data).Body
|
|
8705
8780
|
});
|
|
8706
|
-
case "validateCaptcha": return await GlobalGetData(data
|
|
8781
|
+
case "validateCaptcha": return await GlobalGetData(data.methodType, {
|
|
8707
8782
|
...baseRequestConfig,
|
|
8708
8783
|
method: "POST",
|
|
8709
|
-
url: bilibiliApiUrls.validateCaptcha(data
|
|
8710
|
-
data: bilibiliApiUrls.validateCaptcha(data
|
|
8784
|
+
url: bilibiliApiUrls.validateCaptcha(data).Url,
|
|
8785
|
+
data: bilibiliApiUrls.validateCaptcha(data).Body
|
|
8711
8786
|
});
|
|
8712
8787
|
case "videoDanmaku": {
|
|
8713
8788
|
const url = bilibiliApiUrls.getVideoDanmaku({
|
|
8714
|
-
cid: data
|
|
8715
|
-
segment_index: data
|
|
8789
|
+
cid: data.cid,
|
|
8790
|
+
segment_index: data.segment_index
|
|
8716
8791
|
});
|
|
8717
8792
|
try {
|
|
8718
8793
|
const response = await fetchData({
|
|
@@ -8727,7 +8802,7 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
8727
8802
|
data: null,
|
|
8728
8803
|
amagiError: {
|
|
8729
8804
|
...response.error.amagiError,
|
|
8730
|
-
requestType: data
|
|
8805
|
+
requestType: data.methodType
|
|
8731
8806
|
}
|
|
8732
8807
|
});
|
|
8733
8808
|
throw networkError;
|
|
@@ -8739,20 +8814,19 @@ const fetchBilibili = async (data$1, cookie, requestConfig) => {
|
|
|
8739
8814
|
};
|
|
8740
8815
|
} catch (error) {
|
|
8741
8816
|
if (error && typeof error === "object" && "code" in error) return error;
|
|
8742
|
-
const Err = {
|
|
8743
|
-
errorDescription: `获取弹幕数据失败:${error instanceof Error ? error.message : "未知错误"}`,
|
|
8744
|
-
requestType: data$1.methodType,
|
|
8745
|
-
requestUrl: url
|
|
8746
|
-
};
|
|
8747
8817
|
return {
|
|
8748
|
-
code:
|
|
8818
|
+
code: "UNKNOWN_ERROR",
|
|
8749
8819
|
data: null,
|
|
8750
|
-
amagiError:
|
|
8820
|
+
amagiError: {
|
|
8821
|
+
errorDescription: `获取弹幕数据失败:${error instanceof Error ? error.message : "未知错误"}`,
|
|
8822
|
+
requestType: data.methodType,
|
|
8823
|
+
requestUrl: url
|
|
8824
|
+
}
|
|
8751
8825
|
};
|
|
8752
8826
|
}
|
|
8753
8827
|
}
|
|
8754
8828
|
default:
|
|
8755
|
-
|
|
8829
|
+
emitLogWarn(`未知的B站数据接口:「${data.methodType}」`);
|
|
8756
8830
|
return null;
|
|
8757
8831
|
}
|
|
8758
8832
|
};
|
|
@@ -8788,22 +8862,25 @@ const GlobalGetData = async (type, options, retryCount = 0) => {
|
|
|
8788
8862
|
requestUrl: options.url
|
|
8789
8863
|
};
|
|
8790
8864
|
warningMessage = `
|
|
8791
|
-
|
|
8865
|
+
获取响应数据失败!原因:接口返回内容为空,你的B站ck可能已经失效!
|
|
8792
8866
|
请求类型:「${type}」
|
|
8793
8867
|
请求URL:${options.url}
|
|
8794
8868
|
`;
|
|
8795
|
-
|
|
8869
|
+
emitLogWarn(warningMessage);
|
|
8796
8870
|
const riskError = new Error(Err.errorDescription);
|
|
8797
8871
|
Object.assign(riskError, {
|
|
8798
|
-
code:
|
|
8872
|
+
code: "-352",
|
|
8799
8873
|
data: result,
|
|
8800
8874
|
amagiError: Err
|
|
8801
8875
|
});
|
|
8802
8876
|
throw riskError;
|
|
8803
8877
|
}
|
|
8804
|
-
|
|
8878
|
+
const payload = "data" in result ? result.data : "result" in result ? result.result : void 0;
|
|
8879
|
+
const hasPayload = payload !== null && payload !== void 0;
|
|
8880
|
+
const isEmptyObjectPayload = typeof payload === "object" && !Array.isArray(payload) && Object.keys(payload).length === 0;
|
|
8881
|
+
if (result.code !== 0 || !hasPayload || isEmptyObjectPayload) {
|
|
8805
8882
|
if (result.code === -412 && retryCount < MAX_RETRIES) return await GlobalGetData(type, options, retryCount + 1);
|
|
8806
|
-
const errorMessage = bilibiliErrorCodeMap[result.code] ||
|
|
8883
|
+
const errorMessage = bilibiliErrorCodeMap[result.code] || isEmptyObjectPayload && "请求成功但无返回内容" || (result.message ?? "未知错误");
|
|
8807
8884
|
const Err = {
|
|
8808
8885
|
errorDescription: `获取响应数据失败!原因:${errorMessage}!`,
|
|
8809
8886
|
requestType: type ?? "未知请求类型",
|
|
@@ -8811,12 +8888,12 @@ const GlobalGetData = async (type, options, retryCount = 0) => {
|
|
|
8811
8888
|
responseCode: result.code
|
|
8812
8889
|
};
|
|
8813
8890
|
warningMessage = `
|
|
8814
|
-
获取响应数据失败!原因:${
|
|
8891
|
+
获取响应数据失败!原因:${errorMessage}
|
|
8815
8892
|
错误代码:${result.code}
|
|
8816
8893
|
请求类型:「${type}」
|
|
8817
8894
|
请求URL:${options.url}
|
|
8818
8895
|
`;
|
|
8819
|
-
|
|
8896
|
+
emitLogWarn(warningMessage);
|
|
8820
8897
|
const apiError = new Error(Err.errorDescription);
|
|
8821
8898
|
Object.assign(apiError, {
|
|
8822
8899
|
code: result.code,
|
|
@@ -8832,7 +8909,7 @@ const GlobalGetData = async (type, options, retryCount = 0) => {
|
|
|
8832
8909
|
amagiMessage: warningMessage
|
|
8833
8910
|
};
|
|
8834
8911
|
return {
|
|
8835
|
-
code:
|
|
8912
|
+
code: "UNKNOWN_ERROR",
|
|
8836
8913
|
data: error.data,
|
|
8837
8914
|
amagiError: {
|
|
8838
8915
|
errorDescription: "未知错误",
|
|
@@ -8899,7 +8976,6 @@ const bilibiliErrorCodeMap = {
|
|
|
8899
8976
|
1e5: "验证码获取失败",
|
|
8900
8977
|
100003: "验证码过期"
|
|
8901
8978
|
};
|
|
8902
|
-
|
|
8903
8979
|
//#endregion
|
|
8904
8980
|
//#region src/utils/errors.ts
|
|
8905
8981
|
/**
|
|
@@ -8981,7 +9057,6 @@ const handleError = (error, requestPath) => {
|
|
|
8981
9057
|
requestPath
|
|
8982
9058
|
};
|
|
8983
9059
|
};
|
|
8984
|
-
|
|
8985
9060
|
//#endregion
|
|
8986
9061
|
//#region src/middleware/validation.ts
|
|
8987
9062
|
/**
|
|
@@ -9028,7 +9103,6 @@ const createKuaishouValidationMiddleware = (methodType) => createValidationMiddl
|
|
|
9028
9103
|
* @returns Express中间件函数
|
|
9029
9104
|
*/
|
|
9030
9105
|
const createXiaohongshuValidationMiddleware = (methodType) => createValidationMiddleware(validateXiaohongshuParams, methodType);
|
|
9031
|
-
|
|
9032
9106
|
//#endregion
|
|
9033
9107
|
//#region src/platform/bilibili/routes.ts
|
|
9034
9108
|
/**
|
|
@@ -9076,7 +9150,6 @@ const createBilibiliRoutes = (cookie, requestConfig = getBilibiliDefaultConfig(c
|
|
|
9076
9150
|
for (const [method, path] of Object.entries(BilibiliMethodRoutes)) router.get(path, createBilibiliValidationMiddleware(method), createBilibiliRouteHandler(method, cookie, requestConfig));
|
|
9077
9151
|
return router;
|
|
9078
9152
|
};
|
|
9079
|
-
|
|
9080
9153
|
//#endregion
|
|
9081
9154
|
//#region src/platform/bilibili/index.ts
|
|
9082
9155
|
/** B站相关功能模块 (工具集) */
|
|
@@ -9090,7 +9163,6 @@ const bilibiliUtils = {
|
|
|
9090
9163
|
bilibiliApiUrls,
|
|
9091
9164
|
api: bilibili
|
|
9092
9165
|
};
|
|
9093
|
-
|
|
9094
9166
|
//#endregion
|
|
9095
9167
|
//#region src/platform/douyin/DouyinApi.ts
|
|
9096
9168
|
/**
|
|
@@ -9108,22 +9180,39 @@ const createDeprecatedStub$2 = (methodName) => {
|
|
|
9108
9180
|
* @deprecated v6 已废弃,请使用 douyinFetcher 或 client.douyin.fetcher 替代
|
|
9109
9181
|
*/
|
|
9110
9182
|
const douyin = {
|
|
9183
|
+
/** @deprecated 请使用 douyinFetcher.fetchTextWork 替代 */
|
|
9111
9184
|
getTextWorkInfo: createDeprecatedStub$2("getTextWorkInfo"),
|
|
9185
|
+
/** @deprecated 请使用 douyinFetcher.parseWork 替代 */
|
|
9112
9186
|
getWorkInfo: createDeprecatedStub$2("getWorkInfo"),
|
|
9187
|
+
/** @deprecated 请使用 douyinFetcher.fetchVideoWork 替代 */
|
|
9113
9188
|
getVideoWorkInfo: createDeprecatedStub$2("getVideoWorkInfo"),
|
|
9189
|
+
/** @deprecated 请使用 douyinFetcher.fetchImageAlbumWork 替代 */
|
|
9114
9190
|
getImageAlbumWorkInfo: createDeprecatedStub$2("getImageAlbumWorkInfo"),
|
|
9191
|
+
/** @deprecated 请使用 douyinFetcher.fetchSlidesWork 替代 */
|
|
9115
9192
|
getSlidesWorkInfo: createDeprecatedStub$2("getSlidesWorkInfo"),
|
|
9193
|
+
/** @deprecated 请使用 douyinFetcher.fetchComments 替代 */
|
|
9116
9194
|
getComments: createDeprecatedStub$2("getComments"),
|
|
9195
|
+
/** @deprecated 请使用 douyinFetcher.fetchCommentReplies 替代 */
|
|
9117
9196
|
getCommentReplies: createDeprecatedStub$2("getCommentReplies"),
|
|
9197
|
+
/** @deprecated 请使用 douyinFetcher.fetchUserProfile 替代 */
|
|
9118
9198
|
getUserProfile: createDeprecatedStub$2("getUserProfile"),
|
|
9199
|
+
/** @deprecated 请使用 douyinFetcher.fetchEmojiList 替代 */
|
|
9119
9200
|
getEmojiList: createDeprecatedStub$2("getEmojiList"),
|
|
9201
|
+
/** @deprecated 请使用 douyinFetcher.fetchDynamicEmojiList 替代 */
|
|
9120
9202
|
getEmojiProList: createDeprecatedStub$2("getEmojiProList"),
|
|
9203
|
+
/** @deprecated 请使用 douyinFetcher.fetchUserVideoList 替代 */
|
|
9121
9204
|
getUserVideos: createDeprecatedStub$2("getUserVideos"),
|
|
9205
|
+
/** @deprecated 请使用 douyinFetcher.fetchMusicInfo 替代 */
|
|
9122
9206
|
getMusicInfo: createDeprecatedStub$2("getMusicInfo"),
|
|
9207
|
+
/** @deprecated 请使用 douyinFetcher.fetchSuggestWords 替代 */
|
|
9123
9208
|
getSuggestWords: createDeprecatedStub$2("getSuggestWords"),
|
|
9209
|
+
/** @deprecated 请使用 douyinFetcher.searchContent 替代 */
|
|
9124
9210
|
search: createDeprecatedStub$2("search"),
|
|
9211
|
+
/** @deprecated 请使用 douyinFetcher.fetchLiveRoomInfo 替代 */
|
|
9125
9212
|
getLiveRoomInfo: createDeprecatedStub$2("getLiveRoomInfo"),
|
|
9213
|
+
/** @deprecated 请使用 douyinFetcher.fetchDanmakuList 替代 */
|
|
9126
9214
|
getDanmaku: createDeprecatedStub$2("getDanmaku"),
|
|
9215
|
+
/** @deprecated 请使用 douyinFetcher 的具体方法替代 */
|
|
9127
9216
|
invoke: createDeprecatedStub$2("invoke")
|
|
9128
9217
|
};
|
|
9129
9218
|
/**
|
|
@@ -9137,7 +9226,6 @@ const createBoundDouyinApi = (_cookie, _requestConfig) => {
|
|
|
9137
9226
|
getSearchData: createDeprecatedStub$2("getSearchData")
|
|
9138
9227
|
};
|
|
9139
9228
|
};
|
|
9140
|
-
|
|
9141
9229
|
//#endregion
|
|
9142
9230
|
//#region src/platform/douyin/routes.ts
|
|
9143
9231
|
/**
|
|
@@ -9185,7 +9273,6 @@ const createDouyinRoutes = (cookie, requestConfig = getDouyinDefaultConfig(cooki
|
|
|
9185
9273
|
for (const [method, path] of Object.entries(DouyinMethodRoutes)) router.get(path, createDouyinValidationMiddleware(method), createDouyinRouteHandler(method, cookie, requestConfig));
|
|
9186
9274
|
return router;
|
|
9187
9275
|
};
|
|
9188
|
-
|
|
9189
9276
|
//#endregion
|
|
9190
9277
|
//#region src/platform/douyin/index.ts
|
|
9191
9278
|
/** 抖音相关功能模块 (工具集) */
|
|
@@ -9194,7 +9281,6 @@ const douyinUtils = {
|
|
|
9194
9281
|
douyinApiUrls,
|
|
9195
9282
|
api: douyin
|
|
9196
9283
|
};
|
|
9197
|
-
|
|
9198
9284
|
//#endregion
|
|
9199
9285
|
//#region src/platform/kuaishou/KuaishouApi.ts
|
|
9200
9286
|
/**
|
|
@@ -9212,11 +9298,17 @@ const createDeprecatedStub$1 = (methodName) => {
|
|
|
9212
9298
|
* @deprecated v6 已废弃,请使用 kuaishouFetcher 或 client.kuaishou.fetcher 替代
|
|
9213
9299
|
*/
|
|
9214
9300
|
const kuaishou = {
|
|
9301
|
+
/** @deprecated 请使用 kuaishouFetcher.fetchVideoWork 替代 */
|
|
9215
9302
|
getWorkInfo: createDeprecatedStub$1("getWorkInfo"),
|
|
9303
|
+
/** @deprecated 请使用 kuaishouFetcher.fetchWorkComments 替代 */
|
|
9216
9304
|
getComments: createDeprecatedStub$1("getComments"),
|
|
9305
|
+
/** @deprecated 请使用 kuaishouFetcher.fetchUserProfile 替代 */
|
|
9217
9306
|
getUserProfile: createDeprecatedStub$1("getUserProfile"),
|
|
9307
|
+
/** @deprecated 请使用 kuaishouFetcher.fetchUserWorkList 替代 */
|
|
9218
9308
|
getUserWorkList: createDeprecatedStub$1("getUserWorkList"),
|
|
9309
|
+
/** @deprecated 请使用 kuaishouFetcher.fetchLiveRoomInfo 替代 */
|
|
9219
9310
|
getLiveRoomInfo: createDeprecatedStub$1("getLiveRoomInfo"),
|
|
9311
|
+
/** @deprecated 请使用 kuaishouFetcher.fetchEmojiList 替代 */
|
|
9220
9312
|
getEmojiList: createDeprecatedStub$1("getEmojiList")
|
|
9221
9313
|
};
|
|
9222
9314
|
/**
|
|
@@ -9227,7 +9319,6 @@ const kuaishou = {
|
|
|
9227
9319
|
const createBoundKuaishouApi = (_cookie, _requestConfig) => {
|
|
9228
9320
|
return { ...kuaishou };
|
|
9229
9321
|
};
|
|
9230
|
-
|
|
9231
9322
|
//#endregion
|
|
9232
9323
|
//#region src/platform/kuaishou/routes.ts
|
|
9233
9324
|
/**
|
|
@@ -9275,7 +9366,6 @@ const createKuaishouRoutes = (cookie, requestConfig = getKuaishouDefaultConfig(c
|
|
|
9275
9366
|
for (const [method, path] of Object.entries(KuaishouMethodRoutes)) router.get(path, createKuaishouValidationMiddleware(method), createKuaishouRouteHandler(method, cookie, requestConfig));
|
|
9276
9367
|
return router;
|
|
9277
9368
|
};
|
|
9278
|
-
|
|
9279
9369
|
//#endregion
|
|
9280
9370
|
//#region src/platform/kuaishou/index.ts
|
|
9281
9371
|
/** 快手相关功能模块 (工具集) */
|
|
@@ -9284,19 +9374,9 @@ const kuaishouUtils = {
|
|
|
9284
9374
|
kuaishouApiUrls,
|
|
9285
9375
|
api: kuaishou
|
|
9286
9376
|
};
|
|
9287
|
-
|
|
9288
9377
|
//#endregion
|
|
9289
9378
|
//#region src/platform/xiaohongshu/XiaohongshuApi.ts
|
|
9290
9379
|
/**
|
|
9291
|
-
* 小红书 API 模块 (已废弃)
|
|
9292
|
-
*
|
|
9293
|
-
* 此模块中的 API 已在 v6 版本废弃
|
|
9294
|
-
* 请使用 xiaohongshuFetcher 或 client.xiaohongshu.fetcher 替代
|
|
9295
|
-
*
|
|
9296
|
-
* @module platform/xiaohongshu/XiaohongshuApi
|
|
9297
|
-
* @deprecated v6 已废弃,请使用 fetcher API 替代
|
|
9298
|
-
*/
|
|
9299
|
-
/**
|
|
9300
9380
|
* 创建废弃的 API 存根函数
|
|
9301
9381
|
*/
|
|
9302
9382
|
const createDeprecatedStub = (methodName) => {
|
|
@@ -9311,12 +9391,19 @@ const createDeprecatedStub = (methodName) => {
|
|
|
9311
9391
|
* @deprecated v6 已废弃,请使用 xiaohongshuFetcher 或 client.xiaohongshu.fetcher 替代
|
|
9312
9392
|
*/
|
|
9313
9393
|
const xiaohongshu = {
|
|
9394
|
+
/** @deprecated 请使用 xiaohongshuFetcher.fetchHomeFeed 替代 */
|
|
9314
9395
|
getHomeFeed: createDeprecatedStub("getHomeFeed"),
|
|
9396
|
+
/** @deprecated 请使用 xiaohongshuFetcher.fetchNoteDetail 替代 */
|
|
9315
9397
|
getNote: createDeprecatedStub("getNote"),
|
|
9398
|
+
/** @deprecated 请使用 xiaohongshuFetcher.fetchNoteComments 替代 */
|
|
9316
9399
|
getComments: createDeprecatedStub("getComments"),
|
|
9400
|
+
/** @deprecated 请使用 xiaohongshuFetcher.fetchUserProfile 替代 */
|
|
9317
9401
|
getUser: createDeprecatedStub("getUser"),
|
|
9402
|
+
/** @deprecated 请使用 xiaohongshuFetcher.fetchUserNoteList 替代 */
|
|
9318
9403
|
getUserNotes: createDeprecatedStub("getUserNotes"),
|
|
9404
|
+
/** @deprecated 请使用 xiaohongshuFetcher.searchNotes 替代 */
|
|
9319
9405
|
getSearchNotes: createDeprecatedStub("getSearchNotes"),
|
|
9406
|
+
/** @deprecated 请使用 xiaohongshuFetcher.fetchEmojiList 替代 */
|
|
9320
9407
|
getEmojiList: createDeprecatedStub("getEmojiList")
|
|
9321
9408
|
};
|
|
9322
9409
|
/**
|
|
@@ -9327,7 +9414,6 @@ const xiaohongshu = {
|
|
|
9327
9414
|
const createBoundXiaohongshuApi = (_cookie, _requestConfig) => {
|
|
9328
9415
|
return { ...xiaohongshu };
|
|
9329
9416
|
};
|
|
9330
|
-
|
|
9331
9417
|
//#endregion
|
|
9332
9418
|
//#region src/platform/xiaohongshu/routes.ts
|
|
9333
9419
|
/**
|
|
@@ -9375,7 +9461,6 @@ const createXiaohongshuRoutes = (cookie, requestConfig = getXiaohongshuDefaultCo
|
|
|
9375
9461
|
for (const [method, path] of Object.entries(XiaohongshuMethodRoutes)) router.get(path, createXiaohongshuValidationMiddleware(method), createXiaohongshuRouteHandler(method, cookie, requestConfig));
|
|
9376
9462
|
return router;
|
|
9377
9463
|
};
|
|
9378
|
-
|
|
9379
9464
|
//#endregion
|
|
9380
9465
|
//#region src/platform/xiaohongshu/index.ts
|
|
9381
9466
|
/** 小红书相关功能模块 (工具集) */
|
|
@@ -9384,7 +9469,6 @@ const xiaohongshuUtils = {
|
|
|
9384
9469
|
xiaohongshuApiUrls,
|
|
9385
9470
|
api: xiaohongshu
|
|
9386
9471
|
};
|
|
9387
|
-
|
|
9388
9472
|
//#endregion
|
|
9389
9473
|
//#region src/server/index.ts
|
|
9390
9474
|
/**
|
|
@@ -9434,7 +9518,7 @@ const createAmagiClient = (options) => {
|
|
|
9434
9518
|
* @deprecated v6 已废弃,请使用 douyin.fetcher 替代
|
|
9435
9519
|
* @throws {DeprecatedApiError} 调用时抛出废弃错误
|
|
9436
9520
|
*/
|
|
9437
|
-
const getDouyinData
|
|
9521
|
+
const getDouyinData = (..._args) => {
|
|
9438
9522
|
checkDeprecation("getDouyinData");
|
|
9439
9523
|
throw new Error("getDouyinData 已废弃");
|
|
9440
9524
|
};
|
|
@@ -9442,7 +9526,7 @@ const createAmagiClient = (options) => {
|
|
|
9442
9526
|
* @deprecated v6 已废弃,请使用 bilibili.fetcher 替代
|
|
9443
9527
|
* @throws {DeprecatedApiError} 调用时抛出废弃错误
|
|
9444
9528
|
*/
|
|
9445
|
-
const getBilibiliData
|
|
9529
|
+
const getBilibiliData = (..._args) => {
|
|
9446
9530
|
checkDeprecation("getBilibiliData");
|
|
9447
9531
|
throw new Error("getBilibiliData 已废弃");
|
|
9448
9532
|
};
|
|
@@ -9450,7 +9534,7 @@ const createAmagiClient = (options) => {
|
|
|
9450
9534
|
* @deprecated v6 已废弃,请使用 kuaishou.fetcher 替代
|
|
9451
9535
|
* @throws {DeprecatedApiError} 调用时抛出废弃错误
|
|
9452
9536
|
*/
|
|
9453
|
-
const getKuaishouData
|
|
9537
|
+
const getKuaishouData = (..._args) => {
|
|
9454
9538
|
checkDeprecation("getKuaishouData");
|
|
9455
9539
|
throw new Error("getKuaishouData 已废弃");
|
|
9456
9540
|
};
|
|
@@ -9458,42 +9542,65 @@ const createAmagiClient = (options) => {
|
|
|
9458
9542
|
* @deprecated v6 已废弃,请使用 xiaohongshu.fetcher 替代
|
|
9459
9543
|
* @throws {DeprecatedApiError} 调用时抛出废弃错误
|
|
9460
9544
|
*/
|
|
9461
|
-
const getXiaohongshuData
|
|
9545
|
+
const getXiaohongshuData = (..._args) => {
|
|
9462
9546
|
checkDeprecation("getXiaohongshuData");
|
|
9463
9547
|
throw new Error("getXiaohongshuData 已废弃");
|
|
9464
9548
|
};
|
|
9465
9549
|
return {
|
|
9550
|
+
/** 启动本地HTTP服务 */
|
|
9466
9551
|
startServer,
|
|
9552
|
+
/** 事件系统 */
|
|
9467
9553
|
events: amagiEvents,
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9554
|
+
/**
|
|
9555
|
+
* 注册事件监听器
|
|
9556
|
+
* @param event - 事件名称
|
|
9557
|
+
* @param listener - 事件处理函数
|
|
9558
|
+
*/
|
|
9559
|
+
on: (event, listener) => amagiEvents.on(event, listener),
|
|
9560
|
+
/**
|
|
9561
|
+
* 注册一次性事件监听器
|
|
9562
|
+
* @param event - 事件名称
|
|
9563
|
+
* @param listener - 事件处理函数 (只触发一次)
|
|
9564
|
+
*/
|
|
9565
|
+
once: (event, listener) => amagiEvents.once(event, listener),
|
|
9566
|
+
/** @deprecated v6 已废弃,请使用 douyin.fetcher 替代 */
|
|
9567
|
+
getDouyinData,
|
|
9568
|
+
/** @deprecated v6 已废弃,请使用 bilibili.fetcher 替代 */
|
|
9569
|
+
getBilibiliData,
|
|
9570
|
+
/** @deprecated v6 已废弃,请使用 kuaishou.fetcher 替代 */
|
|
9571
|
+
getKuaishouData,
|
|
9572
|
+
/** @deprecated v6 已废弃,请使用 xiaohongshu.fetcher 替代 */
|
|
9573
|
+
getXiaohongshuData,
|
|
9474
9574
|
douyin: {
|
|
9475
9575
|
...douyinUtils,
|
|
9576
|
+
/** @deprecated 请使用 fetcher 替代 */
|
|
9476
9577
|
api: createBoundDouyinApi(douyinCookie, requestConfig),
|
|
9578
|
+
/** fetcher */
|
|
9477
9579
|
fetcher: createBoundDouyinFetcher(douyinCookie, requestConfig)
|
|
9478
9580
|
},
|
|
9479
9581
|
bilibili: {
|
|
9480
9582
|
...bilibiliUtils,
|
|
9583
|
+
/** @deprecated 请使用 fetcher 替代 */
|
|
9481
9584
|
api: createBoundBilibiliApi(bilibiliCookie, requestConfig),
|
|
9585
|
+
/** fetcher */
|
|
9482
9586
|
fetcher: createBoundBilibiliFetcher(bilibiliCookie, requestConfig)
|
|
9483
9587
|
},
|
|
9484
9588
|
kuaishou: {
|
|
9485
9589
|
...kuaishouUtils,
|
|
9590
|
+
/** @deprecated 请使用 fetcher 替代 */
|
|
9486
9591
|
api: createBoundKuaishouApi(kuaishouCookie, requestConfig),
|
|
9592
|
+
/** fetcher */
|
|
9487
9593
|
fetcher: createBoundKuaishouFetcher(kuaishouCookie, requestConfig)
|
|
9488
9594
|
},
|
|
9489
9595
|
xiaohongshu: {
|
|
9490
9596
|
...xiaohongshuUtils,
|
|
9597
|
+
/** @deprecated 请使用 fetcher 替代 */
|
|
9491
9598
|
api: createBoundXiaohongshuApi(xiaohongshuCookie, requestConfig),
|
|
9599
|
+
/** fetcher */
|
|
9492
9600
|
fetcher: createBoundXiaohongshuFetcher(xiaohongshuCookie, requestConfig)
|
|
9493
9601
|
}
|
|
9494
9602
|
};
|
|
9495
9603
|
};
|
|
9496
|
-
|
|
9497
9604
|
//#endregion
|
|
9498
9605
|
//#region src/types/BilibiliAPIParams.ts
|
|
9499
9606
|
/**
|
|
@@ -9502,136 +9609,133 @@ const createAmagiClient = (options) => {
|
|
|
9502
9609
|
* 对应 CommentParams.type 与 CommentReplyParams.type
|
|
9503
9610
|
* @see https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/readme.md#评论区类型代码
|
|
9504
9611
|
*/
|
|
9505
|
-
let CommentType = /* @__PURE__ */ function(CommentType
|
|
9612
|
+
let CommentType = /* @__PURE__ */ function(CommentType) {
|
|
9506
9613
|
/** 视频稿件:oid 为稿件 avid */
|
|
9507
|
-
CommentType
|
|
9614
|
+
CommentType[CommentType["Video"] = 1] = "Video";
|
|
9508
9615
|
/** 话题:oid 为话题 id */
|
|
9509
|
-
CommentType
|
|
9616
|
+
CommentType[CommentType["Topic"] = 2] = "Topic";
|
|
9510
9617
|
/** 活动:oid 为活动 id */
|
|
9511
|
-
CommentType
|
|
9618
|
+
CommentType[CommentType["Activity"] = 4] = "Activity";
|
|
9512
9619
|
/** 小视频:oid 为小视频 id */
|
|
9513
|
-
CommentType
|
|
9620
|
+
CommentType[CommentType["SmallVideo"] = 5] = "SmallVideo";
|
|
9514
9621
|
/** 小黑屋封禁信息:oid 为封禁公示 id */
|
|
9515
|
-
CommentType
|
|
9622
|
+
CommentType[CommentType["BlockInfo"] = 6] = "BlockInfo";
|
|
9516
9623
|
/** 公告信息:oid 为公告 id */
|
|
9517
|
-
CommentType
|
|
9624
|
+
CommentType[CommentType["Announcement"] = 7] = "Announcement";
|
|
9518
9625
|
/** 直播活动:oid 为直播间 id */
|
|
9519
|
-
CommentType
|
|
9626
|
+
CommentType[CommentType["LiveActivity"] = 8] = "LiveActivity";
|
|
9520
9627
|
/** 活动稿件:oid 含义未知 */
|
|
9521
|
-
CommentType
|
|
9628
|
+
CommentType[CommentType["ActivityVideo"] = 9] = "ActivityVideo";
|
|
9522
9629
|
/** 直播公告:oid 含义未知 */
|
|
9523
|
-
CommentType
|
|
9630
|
+
CommentType[CommentType["LiveAnnouncement"] = 10] = "LiveAnnouncement";
|
|
9524
9631
|
/** 相簿(图片动态):oid 为相簿 id */
|
|
9525
|
-
CommentType
|
|
9632
|
+
CommentType[CommentType["Album"] = 11] = "Album";
|
|
9526
9633
|
/** 专栏:oid 为专栏 cvid */
|
|
9527
|
-
CommentType
|
|
9634
|
+
CommentType[CommentType["Article"] = 12] = "Article";
|
|
9528
9635
|
/** 票务:oid 含义未知 */
|
|
9529
|
-
CommentType
|
|
9636
|
+
CommentType[CommentType["Ticket"] = 13] = "Ticket";
|
|
9530
9637
|
/** 音频:oid 为音频 auid */
|
|
9531
|
-
CommentType
|
|
9638
|
+
CommentType[CommentType["Audio"] = 14] = "Audio";
|
|
9532
9639
|
/** 风纪委员会:oid 为众裁项目 id */
|
|
9533
|
-
CommentType
|
|
9640
|
+
CommentType[CommentType["Jury"] = 15] = "Jury";
|
|
9534
9641
|
/** 点评:oid 含义未知 */
|
|
9535
|
-
CommentType
|
|
9642
|
+
CommentType[CommentType["Review"] = 16] = "Review";
|
|
9536
9643
|
/** 动态(纯文字动态&分享):oid 为动态 id */
|
|
9537
|
-
CommentType
|
|
9644
|
+
CommentType[CommentType["Dynamic"] = 17] = "Dynamic";
|
|
9538
9645
|
/** 播单:oid 含义未知 */
|
|
9539
|
-
CommentType
|
|
9646
|
+
CommentType[CommentType["Playlist"] = 18] = "Playlist";
|
|
9540
9647
|
/** 音乐播单:oid 含义未知 */
|
|
9541
|
-
CommentType
|
|
9648
|
+
CommentType[CommentType["MusicPlaylist"] = 19] = "MusicPlaylist";
|
|
9542
9649
|
/** 漫画:oid 含义未知 */
|
|
9543
|
-
CommentType
|
|
9650
|
+
CommentType[CommentType["Comic1"] = 20] = "Comic1";
|
|
9544
9651
|
/** 漫画:oid 含义未知 */
|
|
9545
|
-
CommentType
|
|
9652
|
+
CommentType[CommentType["Comic2"] = 21] = "Comic2";
|
|
9546
9653
|
/** 漫画:oid 为漫画 mcid */
|
|
9547
|
-
CommentType
|
|
9654
|
+
CommentType[CommentType["Comic"] = 22] = "Comic";
|
|
9548
9655
|
/** 课程:oid 为课程 epid */
|
|
9549
|
-
CommentType
|
|
9550
|
-
return CommentType
|
|
9656
|
+
CommentType[CommentType["Course"] = 33] = "Course";
|
|
9657
|
+
return CommentType;
|
|
9551
9658
|
}({});
|
|
9552
|
-
|
|
9553
9659
|
//#endregion
|
|
9554
9660
|
//#region src/types/ReturnDataType/Bilibili/Dynamic/index.ts
|
|
9555
9661
|
/**
|
|
9556
9662
|
* 转发动态种子动态主体类型枚举
|
|
9557
9663
|
*/
|
|
9558
|
-
let MajorType = /* @__PURE__ */ function(MajorType
|
|
9664
|
+
let MajorType = /* @__PURE__ */ function(MajorType) {
|
|
9559
9665
|
/** 动态失效 */
|
|
9560
|
-
MajorType
|
|
9666
|
+
MajorType["NONE"] = "MAJOR_TYPE_NONE";
|
|
9561
9667
|
/** 图文动态 */
|
|
9562
|
-
MajorType
|
|
9668
|
+
MajorType["OPUS"] = "MAJOR_TYPE_OPUS";
|
|
9563
9669
|
/** 视频 */
|
|
9564
|
-
MajorType
|
|
9670
|
+
MajorType["ARCHIVE"] = "MAJOR_TYPE_ARCHIVE";
|
|
9565
9671
|
/** 剧集更新 */
|
|
9566
|
-
MajorType
|
|
9672
|
+
MajorType["PGC"] = "MAJOR_TYPE_PGC";
|
|
9567
9673
|
/** 课程 */
|
|
9568
|
-
MajorType
|
|
9674
|
+
MajorType["COURSES"] = "MAJOR_TYPE_COURSES";
|
|
9569
9675
|
/** 带图动态 */
|
|
9570
|
-
MajorType
|
|
9676
|
+
MajorType["DRAW"] = "MAJOR_TYPE_DRAW";
|
|
9571
9677
|
/** 文章 */
|
|
9572
|
-
MajorType
|
|
9678
|
+
MajorType["ARTICLE"] = "MAJOR_TYPE_ARTICLE";
|
|
9573
9679
|
/** 音频更新 */
|
|
9574
|
-
MajorType
|
|
9680
|
+
MajorType["MUSIC"] = "MAJOR_TYPE_MUSIC";
|
|
9575
9681
|
/** 一般类型 */
|
|
9576
|
-
MajorType
|
|
9682
|
+
MajorType["COMMON"] = "MAJOR_TYPE_COMMON";
|
|
9577
9683
|
/** 直播间分享 */
|
|
9578
|
-
MajorType
|
|
9684
|
+
MajorType["LIVE"] = "MAJOR_TYPE_LIVE";
|
|
9579
9685
|
/** 媒体列表 */
|
|
9580
|
-
MajorType
|
|
9686
|
+
MajorType["MEDIALIST"] = "MAJOR_TYPE_MEDIALIST";
|
|
9581
9687
|
/** 小程序 */
|
|
9582
|
-
MajorType
|
|
9688
|
+
MajorType["APPLET"] = "MAJOR_TYPE_APPLET";
|
|
9583
9689
|
/** 订阅 */
|
|
9584
|
-
MajorType
|
|
9690
|
+
MajorType["SUBSCRIPTION"] = "MAJOR_TYPE_SUBSCRIPTION";
|
|
9585
9691
|
/** 直播状态 */
|
|
9586
|
-
MajorType
|
|
9692
|
+
MajorType["LIVE_RCMD"] = "MAJOR_TYPE_LIVE_RCMD";
|
|
9587
9693
|
/** 合集更新 */
|
|
9588
|
-
MajorType
|
|
9694
|
+
MajorType["UGC_SEASON"] = "MAJOR_TYPE_UGC_SEASON";
|
|
9589
9695
|
/** 新订阅 */
|
|
9590
|
-
MajorType
|
|
9696
|
+
MajorType["SUBSCRIPTION_NEW"] = "MAJOR_TYPE_SUBSCRIPTION_NEW";
|
|
9591
9697
|
/** 充电相关 */
|
|
9592
|
-
MajorType
|
|
9593
|
-
return MajorType
|
|
9698
|
+
MajorType["UPOWER_COMMON"] = "MAJOR_TYPE_UPOWER_COMMON";
|
|
9699
|
+
return MajorType;
|
|
9594
9700
|
}({});
|
|
9595
9701
|
/**
|
|
9596
9702
|
* 相关内容卡片类型枚举
|
|
9597
9703
|
* 用于标识动态中附加的相关内容卡片的类型
|
|
9598
9704
|
*/
|
|
9599
|
-
let AdditionalType = /* @__PURE__ */ function(AdditionalType
|
|
9705
|
+
let AdditionalType = /* @__PURE__ */ function(AdditionalType) {
|
|
9600
9706
|
/** 无相关内容 */
|
|
9601
|
-
AdditionalType
|
|
9707
|
+
AdditionalType["NONE"] = "ADDITIONAL_TYPE_NONE";
|
|
9602
9708
|
/** 剧集相关 */
|
|
9603
|
-
AdditionalType
|
|
9709
|
+
AdditionalType["PGC"] = "ADDITIONAL_TYPE_PGC";
|
|
9604
9710
|
/** 商品信息 */
|
|
9605
|
-
AdditionalType
|
|
9711
|
+
AdditionalType["GOODS"] = "ADDITIONAL_TYPE_GOODS";
|
|
9606
9712
|
/** 投票 */
|
|
9607
|
-
AdditionalType
|
|
9713
|
+
AdditionalType["VOTE"] = "ADDITIONAL_TYPE_VOTE";
|
|
9608
9714
|
/** 一般类型 */
|
|
9609
|
-
AdditionalType
|
|
9715
|
+
AdditionalType["COMMON"] = "ADDITIONAL_TYPE_COMMON";
|
|
9610
9716
|
/** 比赛信息 */
|
|
9611
|
-
AdditionalType
|
|
9717
|
+
AdditionalType["MATCH"] = "ADDITIONAL_TYPE_MATCH";
|
|
9612
9718
|
/** UP主推荐 */
|
|
9613
|
-
AdditionalType
|
|
9719
|
+
AdditionalType["UP_RCMD"] = "ADDITIONAL_TYPE_UP_RCMD";
|
|
9614
9720
|
/** 视频跳转 */
|
|
9615
|
-
AdditionalType
|
|
9721
|
+
AdditionalType["UGC"] = "ADDITIONAL_TYPE_UGC";
|
|
9616
9722
|
/** 直播预约 */
|
|
9617
|
-
AdditionalType
|
|
9723
|
+
AdditionalType["RESERVE"] = "ADDITIONAL_TYPE_RESERVE";
|
|
9618
9724
|
/** 充电专属抽奖 */
|
|
9619
|
-
AdditionalType
|
|
9620
|
-
return AdditionalType
|
|
9725
|
+
AdditionalType["UPOWER_LOTTERY"] = "ADDITIONAL_TYPE_UPOWER_LOTTERY";
|
|
9726
|
+
return AdditionalType;
|
|
9621
9727
|
}({});
|
|
9622
|
-
|
|
9623
9728
|
//#endregion
|
|
9624
|
-
//#region src/types/ReturnDataType/Bilibili/DynamicInfo.ts
|
|
9625
|
-
let DynamicType = /* @__PURE__ */ function(DynamicType
|
|
9626
|
-
DynamicType
|
|
9627
|
-
DynamicType
|
|
9628
|
-
DynamicType
|
|
9629
|
-
DynamicType
|
|
9630
|
-
DynamicType
|
|
9631
|
-
DynamicType
|
|
9632
|
-
return DynamicType
|
|
9729
|
+
//#region src/types/ReturnDataType/Bilibili/DynamicInfo/index.ts
|
|
9730
|
+
let DynamicType = /* @__PURE__ */ function(DynamicType) {
|
|
9731
|
+
DynamicType["AV"] = "DYNAMIC_TYPE_AV";
|
|
9732
|
+
DynamicType["DRAW"] = "DYNAMIC_TYPE_DRAW";
|
|
9733
|
+
DynamicType["WORD"] = "DYNAMIC_TYPE_WORD";
|
|
9734
|
+
DynamicType["LIVE_RCMD"] = "DYNAMIC_TYPE_LIVE_RCMD";
|
|
9735
|
+
DynamicType["FORWARD"] = "DYNAMIC_TYPE_FORWARD";
|
|
9736
|
+
DynamicType["ARTICLE"] = "DYNAMIC_TYPE_ARTICLE";
|
|
9737
|
+
return DynamicType;
|
|
9633
9738
|
}({});
|
|
9634
|
-
|
|
9635
9739
|
//#endregion
|
|
9636
9740
|
//#region src/types/method-keys.ts
|
|
9637
9741
|
/**
|
|
@@ -9890,7 +9994,6 @@ const MethodMaps = {
|
|
|
9890
9994
|
toFetcher: XiaohongshuMethodToFetcher
|
|
9891
9995
|
}
|
|
9892
9996
|
};
|
|
9893
|
-
|
|
9894
9997
|
//#endregion
|
|
9895
9998
|
//#region src/types/api-spec.ts
|
|
9896
9999
|
const DouyinMethodMapping = {
|
|
@@ -9912,8 +10015,7 @@ const DouyinMethodMapping = {
|
|
|
9912
10015
|
动态表情数据: "fetchDynamicEmojiList",
|
|
9913
10016
|
弹幕数据: "fetchDanmakuList"
|
|
9914
10017
|
};
|
|
9915
|
-
|
|
9916
|
-
const DouyinMethodReverseMapping = Object.fromEntries(Object.entries(DouyinMethodMapping).map(([k, v]) => [v, k]));
|
|
10018
|
+
Object.fromEntries(Object.entries(DouyinMethodMapping).map(([k, v]) => [v, k]));
|
|
9917
10019
|
const BilibiliMethodMapping = {
|
|
9918
10020
|
单个视频作品数据: "fetchVideoInfo",
|
|
9919
10021
|
单个视频下载信息数据: "fetchVideoStreamUrl",
|
|
@@ -9943,8 +10045,7 @@ const BilibiliMethodMapping = {
|
|
|
9943
10045
|
从_v_voucher_申请_captcha: "requestCaptchaFromVoucher",
|
|
9944
10046
|
验证验证码结果: "validateCaptchaResult"
|
|
9945
10047
|
};
|
|
9946
|
-
|
|
9947
|
-
const BilibiliMethodReverseMapping = Object.fromEntries(Object.entries(BilibiliMethodMapping).map(([k, v]) => [v, k]));
|
|
10048
|
+
Object.fromEntries(Object.entries(BilibiliMethodMapping).map(([k, v]) => [v, k]));
|
|
9948
10049
|
const KuaishouMethodMapping = {
|
|
9949
10050
|
单个视频作品数据: "fetchVideoWork",
|
|
9950
10051
|
评论数据: "fetchWorkComments",
|
|
@@ -9953,8 +10054,7 @@ const KuaishouMethodMapping = {
|
|
|
9953
10054
|
直播间信息数据: "fetchLiveRoomInfo",
|
|
9954
10055
|
Emoji数据: "fetchEmojiList"
|
|
9955
10056
|
};
|
|
9956
|
-
|
|
9957
|
-
const KuaishouMethodReverseMapping = Object.fromEntries(Object.entries(KuaishouMethodMapping).map(([k, v]) => [v, k]));
|
|
10057
|
+
Object.fromEntries(Object.entries(KuaishouMethodMapping).map(([k, v]) => [v, k]));
|
|
9958
10058
|
const XiaohongshuMethodMapping = {
|
|
9959
10059
|
首页推荐数据: "fetchHomeFeed",
|
|
9960
10060
|
单个笔记数据: "fetchNoteDetail",
|
|
@@ -9964,8 +10064,7 @@ const XiaohongshuMethodMapping = {
|
|
|
9964
10064
|
表情列表: "fetchEmojiList",
|
|
9965
10065
|
搜索笔记: "searchNotes"
|
|
9966
10066
|
};
|
|
9967
|
-
|
|
9968
|
-
const XiaohongshuMethodReverseMapping = Object.fromEntries(Object.entries(XiaohongshuMethodMapping).map(([k, v]) => [v, k]));
|
|
10067
|
+
Object.fromEntries(Object.entries(XiaohongshuMethodMapping).map(([k, v]) => [v, k]));
|
|
9969
10068
|
/**
|
|
9970
10069
|
* Douyin HTTP API 路由
|
|
9971
10070
|
*
|
|
@@ -10073,7 +10172,6 @@ function getApiRoute(platform, methodType) {
|
|
|
10073
10172
|
xiaohongshu: XiaohongshuApiRoutes
|
|
10074
10173
|
}[platform][methodType];
|
|
10075
10174
|
}
|
|
10076
|
-
|
|
10077
10175
|
//#endregion
|
|
10078
10176
|
//#region src/index.ts
|
|
10079
10177
|
/**
|
|
@@ -10081,7 +10179,7 @@ function getApiRoute(platform, methodType) {
|
|
|
10081
10179
|
* 构建后使用 __VERSION__,开发环境从 package.json 读取
|
|
10082
10180
|
*/
|
|
10083
10181
|
const getVersion = () => {
|
|
10084
|
-
return "6.
|
|
10182
|
+
return "6.2.0";
|
|
10085
10183
|
};
|
|
10086
10184
|
const VERSION = getVersion();
|
|
10087
10185
|
/**
|
|
@@ -10128,7 +10226,11 @@ const CreateApp = CreateAmagiApp;
|
|
|
10128
10226
|
/** After instantiation, it can interact with the specified platform API to quickly obtain data. */
|
|
10129
10227
|
const Client = CreateApp;
|
|
10130
10228
|
const amagi = Client;
|
|
10131
|
-
|
|
10229
|
+
/*!
|
|
10230
|
+
* @ikenxuan/amagi
|
|
10231
|
+
* Copyright(c) 2023 ikenxuan
|
|
10232
|
+
* GPL-3.0 Licensed
|
|
10233
|
+
*/
|
|
10132
10234
|
//#endregion
|
|
10133
10235
|
exports.AdditionalType = AdditionalType;
|
|
10134
10236
|
exports.ApiError = ApiError;
|
|
@@ -10285,4 +10387,4 @@ exports.xiaohongshu = xiaohongshu;
|
|
|
10285
10387
|
exports.xiaohongshuApiUrls = xiaohongshuApiUrls;
|
|
10286
10388
|
exports.xiaohongshuFetcher = xiaohongshuFetcher;
|
|
10287
10389
|
exports.xiaohongshuSign = xiaohongshuSign;
|
|
10288
|
-
exports.xiaohongshuUtils = xiaohongshuUtils;
|
|
10390
|
+
exports.xiaohongshuUtils = xiaohongshuUtils;
|