@jackwener/opencli 0.9.5 → 0.9.8
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/.github/ISSUE_TEMPLATE/bug_report.yml +83 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +42 -0
- package/.github/ISSUE_TEMPLATE/new_site_adapter.yml +57 -0
- package/.github/dependabot.yml +27 -0
- package/.github/pull_request_template.md +24 -0
- package/.github/workflows/ci.yml +14 -8
- package/.github/workflows/e2e-headed.yml +6 -2
- package/.github/workflows/pkg-pr-new.yml +2 -2
- package/.github/workflows/release-please.yml +25 -0
- package/.github/workflows/release.yml +2 -2
- package/.github/workflows/security.yml +36 -0
- package/CLI-ELECTRON.md +89 -36
- package/CONTRIBUTING.md +167 -0
- package/README.md +98 -32
- package/README.zh-CN.md +99 -33
- package/dist/browser/discover.js +22 -7
- package/dist/browser.test.js +23 -0
- package/dist/build-manifest.d.ts +26 -0
- package/dist/build-manifest.js +132 -60
- package/dist/build-manifest.test.d.ts +1 -0
- package/dist/build-manifest.test.js +26 -0
- package/dist/cli-manifest.json +1875 -271
- package/dist/clis/antigravity/model.js +2 -2
- package/dist/clis/antigravity/send.js +2 -2
- package/dist/clis/bilibili/download.d.ts +10 -0
- package/dist/clis/bilibili/download.js +135 -0
- package/dist/clis/chatgpt/ask.d.ts +1 -0
- package/dist/clis/chatgpt/ask.js +68 -0
- package/dist/clis/chatgpt/send.js +11 -0
- package/dist/clis/chatwise/ask.d.ts +1 -0
- package/dist/clis/chatwise/ask.js +76 -0
- package/dist/clis/chatwise/export.d.ts +1 -0
- package/dist/clis/chatwise/export.js +46 -0
- package/dist/clis/chatwise/history.d.ts +1 -0
- package/dist/clis/chatwise/history.js +43 -0
- package/dist/clis/chatwise/model.d.ts +1 -0
- package/dist/clis/chatwise/model.js +81 -0
- package/dist/clis/chatwise/new.d.ts +1 -0
- package/dist/clis/chatwise/new.js +18 -0
- package/dist/clis/chatwise/read.d.ts +1 -0
- package/dist/clis/chatwise/read.js +39 -0
- package/dist/clis/chatwise/screenshot.d.ts +1 -0
- package/dist/clis/chatwise/screenshot.js +27 -0
- package/dist/clis/chatwise/send.d.ts +1 -0
- package/dist/clis/chatwise/send.js +45 -0
- package/dist/clis/chatwise/status.d.ts +1 -0
- package/dist/clis/chatwise/status.js +22 -0
- package/dist/clis/codex/ask.d.ts +1 -0
- package/dist/clis/codex/ask.js +67 -0
- package/dist/clis/codex/export.d.ts +1 -0
- package/dist/clis/codex/export.js +37 -0
- package/dist/clis/codex/history.d.ts +1 -0
- package/dist/clis/codex/history.js +43 -0
- package/dist/clis/codex/read.js +3 -5
- package/dist/clis/codex/screenshot.d.ts +1 -0
- package/dist/clis/codex/screenshot.js +27 -0
- package/dist/clis/codex/send.js +3 -6
- package/dist/clis/codex/status.js +2 -1
- package/dist/clis/cursor/ask.d.ts +1 -0
- package/dist/clis/cursor/ask.js +69 -0
- package/dist/clis/cursor/composer.js +9 -28
- package/dist/clis/cursor/export.d.ts +1 -0
- package/dist/clis/cursor/export.js +51 -0
- package/dist/clis/cursor/history.d.ts +1 -0
- package/dist/clis/cursor/history.js +43 -0
- package/dist/clis/cursor/new.js +4 -13
- package/dist/clis/cursor/screenshot.d.ts +1 -0
- package/dist/clis/cursor/screenshot.js +31 -0
- package/dist/clis/discord-app/channels.d.ts +1 -0
- package/dist/clis/discord-app/channels.js +45 -0
- package/dist/clis/discord-app/members.d.ts +1 -0
- package/dist/clis/discord-app/members.js +38 -0
- package/dist/clis/discord-app/read.d.ts +1 -0
- package/dist/clis/discord-app/read.js +45 -0
- package/dist/clis/discord-app/search.d.ts +1 -0
- package/dist/clis/discord-app/search.js +56 -0
- package/dist/clis/discord-app/send.d.ts +1 -0
- package/dist/clis/discord-app/send.js +27 -0
- package/dist/clis/discord-app/servers.d.ts +1 -0
- package/dist/clis/discord-app/servers.js +36 -0
- package/dist/clis/discord-app/status.d.ts +1 -0
- package/dist/clis/discord-app/status.js +16 -0
- package/dist/clis/feishu/new.d.ts +1 -0
- package/dist/clis/feishu/new.js +27 -0
- package/dist/clis/feishu/read.d.ts +1 -0
- package/dist/clis/feishu/read.js +40 -0
- package/dist/clis/feishu/search.d.ts +1 -0
- package/dist/clis/feishu/search.js +30 -0
- package/dist/clis/feishu/send.d.ts +1 -0
- package/dist/clis/feishu/send.js +39 -0
- package/dist/clis/feishu/status.d.ts +1 -0
- package/dist/clis/feishu/status.js +28 -0
- package/dist/clis/grok/ask.d.ts +1 -0
- package/dist/clis/grok/ask.js +82 -0
- package/dist/clis/grok/debug.d.ts +1 -0
- package/dist/clis/grok/debug.js +45 -0
- package/dist/clis/jimeng/generate.yaml +84 -0
- package/dist/clis/jimeng/history.yaml +47 -0
- package/dist/clis/linux-do/categories.yaml +41 -0
- package/dist/clis/linux-do/category.yaml +49 -0
- package/dist/clis/linux-do/hot.yaml +50 -0
- package/dist/clis/linux-do/latest.yaml +40 -0
- package/dist/clis/linux-do/search.yaml +45 -0
- package/dist/clis/linux-do/topic.yaml +38 -0
- package/dist/clis/notion/export.d.ts +1 -0
- package/dist/clis/notion/export.js +31 -0
- package/dist/clis/notion/favorites.d.ts +1 -0
- package/dist/clis/notion/favorites.js +84 -0
- package/dist/clis/notion/new.d.ts +1 -0
- package/dist/clis/notion/new.js +34 -0
- package/dist/clis/notion/read.d.ts +1 -0
- package/dist/clis/notion/read.js +30 -0
- package/dist/clis/notion/search.d.ts +1 -0
- package/dist/clis/notion/search.js +46 -0
- package/dist/clis/notion/sidebar.d.ts +1 -0
- package/dist/clis/notion/sidebar.js +41 -0
- package/dist/clis/notion/status.d.ts +1 -0
- package/dist/clis/notion/status.js +16 -0
- package/dist/clis/notion/write.d.ts +1 -0
- package/dist/clis/notion/write.js +40 -0
- package/dist/clis/twitter/download.d.ts +8 -0
- package/dist/clis/twitter/download.js +204 -0
- package/dist/clis/wechat/chats.d.ts +1 -0
- package/dist/clis/wechat/chats.js +28 -0
- package/dist/clis/wechat/contacts.d.ts +1 -0
- package/dist/clis/wechat/contacts.js +28 -0
- package/dist/clis/wechat/read.d.ts +1 -0
- package/dist/clis/wechat/read.js +58 -0
- package/dist/clis/wechat/search.d.ts +1 -0
- package/dist/clis/wechat/search.js +31 -0
- package/dist/clis/wechat/send.d.ts +1 -0
- package/dist/clis/wechat/send.js +42 -0
- package/dist/clis/wechat/status.d.ts +1 -0
- package/dist/clis/wechat/status.js +29 -0
- package/dist/clis/xiaohongshu/creator-note-detail.d.ts +10 -0
- package/dist/clis/xiaohongshu/creator-note-detail.js +88 -0
- package/dist/clis/xiaohongshu/creator-notes.d.ts +11 -0
- package/dist/clis/xiaohongshu/creator-notes.js +109 -0
- package/dist/clis/xiaohongshu/creator-profile.d.ts +10 -0
- package/dist/clis/xiaohongshu/creator-profile.js +54 -0
- package/dist/clis/xiaohongshu/creator-stats.d.ts +10 -0
- package/dist/clis/xiaohongshu/creator-stats.js +74 -0
- package/dist/clis/xiaohongshu/download.d.ts +7 -0
- package/dist/clis/xiaohongshu/download.js +155 -0
- package/dist/clis/xiaohongshu/search.js +1 -1
- package/dist/clis/xiaohongshu/user-helpers.d.ts +15 -0
- package/dist/clis/xiaohongshu/user-helpers.js +67 -0
- package/dist/clis/xiaohongshu/user-helpers.test.d.ts +1 -0
- package/dist/clis/xiaohongshu/user-helpers.test.js +81 -0
- package/dist/clis/xiaohongshu/user.js +46 -29
- package/dist/clis/zhihu/download.d.ts +11 -0
- package/dist/clis/zhihu/download.js +186 -0
- package/dist/clis/zhihu/download.test.d.ts +1 -0
- package/dist/clis/zhihu/download.test.js +10 -0
- package/dist/download/index.d.ts +79 -0
- package/dist/download/index.js +325 -0
- package/dist/download/progress.d.ts +36 -0
- package/dist/download/progress.js +111 -0
- package/dist/engine.test.js +15 -0
- package/dist/main.js +16 -3
- package/dist/pipeline/registry.js +2 -0
- package/dist/pipeline/steps/download.d.ts +34 -0
- package/dist/pipeline/steps/download.js +251 -0
- package/dist/pipeline/template.js +28 -0
- package/package.json +4 -3
- package/scripts/test-site.mjs +70 -0
- package/src/browser/discover.ts +23 -7
- package/src/browser.test.ts +23 -0
- package/src/build-manifest.test.ts +28 -0
- package/src/build-manifest.ts +147 -57
- package/src/clis/antigravity/README.md +2 -3
- package/src/clis/antigravity/README.zh-CN.md +2 -3
- package/src/clis/antigravity/SKILL.md +1 -1
- package/src/clis/antigravity/model.ts +2 -2
- package/src/clis/antigravity/send.ts +2 -2
- package/src/clis/bilibili/download.ts +161 -0
- package/src/clis/chatgpt/README.md +25 -16
- package/src/clis/chatgpt/README.zh-CN.md +27 -18
- package/src/clis/chatgpt/ask.ts +77 -0
- package/src/clis/chatgpt/send.ts +12 -0
- package/src/clis/chatwise/README.md +38 -0
- package/src/clis/chatwise/README.zh-CN.md +38 -0
- package/src/clis/chatwise/ask.ts +87 -0
- package/src/clis/chatwise/export.ts +51 -0
- package/src/clis/chatwise/history.ts +47 -0
- package/src/clis/chatwise/model.ts +87 -0
- package/src/clis/chatwise/new.ts +21 -0
- package/src/clis/chatwise/read.ts +42 -0
- package/src/clis/chatwise/screenshot.ts +33 -0
- package/src/clis/chatwise/send.ts +50 -0
- package/src/clis/chatwise/status.ts +25 -0
- package/src/clis/codex/ask.ts +77 -0
- package/src/clis/codex/export.ts +42 -0
- package/src/clis/codex/extract-diff.ts +1 -0
- package/src/clis/codex/history.ts +47 -0
- package/src/clis/codex/read.ts +5 -6
- package/src/clis/codex/screenshot.ts +33 -0
- package/src/clis/codex/send.ts +6 -7
- package/src/clis/codex/status.ts +4 -2
- package/src/clis/cursor/ask.ts +81 -0
- package/src/clis/cursor/composer.ts +9 -30
- package/src/clis/cursor/export.ts +57 -0
- package/src/clis/cursor/history.ts +47 -0
- package/src/clis/cursor/new.ts +4 -15
- package/src/clis/cursor/screenshot.ts +38 -0
- package/src/clis/discord-app/README.md +28 -0
- package/src/clis/discord-app/README.zh-CN.md +28 -0
- package/src/clis/discord-app/channels.ts +48 -0
- package/src/clis/discord-app/members.ts +41 -0
- package/src/clis/discord-app/read.ts +49 -0
- package/src/clis/discord-app/search.ts +64 -0
- package/src/clis/discord-app/send.ts +32 -0
- package/src/clis/discord-app/servers.ts +39 -0
- package/src/clis/discord-app/status.ts +18 -0
- package/src/clis/feishu/README.md +20 -0
- package/src/clis/feishu/README.zh-CN.md +20 -0
- package/src/clis/feishu/new.ts +32 -0
- package/src/clis/feishu/read.ts +48 -0
- package/src/clis/feishu/search.ts +35 -0
- package/src/clis/feishu/send.ts +46 -0
- package/src/clis/feishu/status.ts +34 -0
- package/src/clis/grok/ask.ts +90 -0
- package/src/clis/grok/debug.ts +49 -0
- package/src/clis/jimeng/generate.yaml +84 -0
- package/src/clis/jimeng/history.yaml +47 -0
- package/src/clis/linux-do/categories.yaml +41 -0
- package/src/clis/linux-do/category.yaml +49 -0
- package/src/clis/linux-do/hot.yaml +50 -0
- package/src/clis/linux-do/latest.yaml +40 -0
- package/src/clis/linux-do/search.yaml +45 -0
- package/src/clis/linux-do/topic.yaml +38 -0
- package/src/clis/notion/README.md +29 -0
- package/src/clis/notion/README.zh-CN.md +29 -0
- package/src/clis/notion/export.ts +36 -0
- package/src/clis/notion/favorites.ts +87 -0
- package/src/clis/notion/new.ts +39 -0
- package/src/clis/notion/read.ts +33 -0
- package/src/clis/notion/search.ts +54 -0
- package/src/clis/notion/sidebar.ts +44 -0
- package/src/clis/notion/status.ts +18 -0
- package/src/clis/notion/write.ts +45 -0
- package/src/clis/twitter/download.ts +227 -0
- package/src/clis/wechat/README.md +28 -0
- package/src/clis/wechat/README.zh-CN.md +28 -0
- package/src/clis/wechat/chats.ts +33 -0
- package/src/clis/wechat/contacts.ts +33 -0
- package/src/clis/wechat/read.ts +72 -0
- package/src/clis/wechat/search.ts +36 -0
- package/src/clis/wechat/send.ts +49 -0
- package/src/clis/wechat/status.ts +35 -0
- package/src/clis/xiaohongshu/creator-note-detail.ts +95 -0
- package/src/clis/xiaohongshu/creator-notes.ts +116 -0
- package/src/clis/xiaohongshu/creator-profile.ts +60 -0
- package/src/clis/xiaohongshu/creator-stats.ts +81 -0
- package/src/clis/xiaohongshu/download.ts +173 -0
- package/src/clis/xiaohongshu/search.ts +1 -1
- package/src/clis/xiaohongshu/user-helpers.test.ts +106 -0
- package/src/clis/xiaohongshu/user-helpers.ts +85 -0
- package/src/clis/xiaohongshu/user.ts +52 -32
- package/src/clis/zhihu/download.test.ts +12 -0
- package/src/clis/zhihu/download.ts +223 -0
- package/src/download/index.ts +395 -0
- package/src/download/progress.ts +125 -0
- package/src/engine.test.ts +17 -0
- package/src/main.ts +12 -3
- package/src/pipeline/registry.ts +2 -0
- package/src/pipeline/steps/download.ts +310 -0
- package/src/pipeline/template.ts +26 -0
- package/tests/e2e/browser-auth.test.ts +25 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Xiaohongshu Creator Note Detail — per-note analytics breakdown.
|
|
3
|
+
*
|
|
4
|
+
* Uses the creator.xiaohongshu.com internal API (cookie auth).
|
|
5
|
+
* Returns total reads, engagement, likes, collects, comments, shares
|
|
6
|
+
* for a specific note, split by channel (organic vs promoted vs video).
|
|
7
|
+
*
|
|
8
|
+
* Requires: logged into creator.xiaohongshu.com in Chrome.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { cli, Strategy } from '../../registry.js';
|
|
12
|
+
|
|
13
|
+
cli({
|
|
14
|
+
site: 'xiaohongshu',
|
|
15
|
+
name: 'creator-note-detail',
|
|
16
|
+
description: '小红书单篇笔记详细数据 (阅读/互动/点赞/收藏/评论/分享,区分自然流量/推广/视频)',
|
|
17
|
+
domain: 'creator.xiaohongshu.com',
|
|
18
|
+
strategy: Strategy.COOKIE,
|
|
19
|
+
browser: true,
|
|
20
|
+
args: [
|
|
21
|
+
{ name: 'note_id', type: 'string', required: true, help: 'Note ID (from note URL or creator-notes command)' },
|
|
22
|
+
],
|
|
23
|
+
columns: ['channel', 'reads', 'engagement', 'likes', 'collects', 'comments', 'shares'],
|
|
24
|
+
func: async (page, kwargs) => {
|
|
25
|
+
const noteId: string = kwargs.note_id;
|
|
26
|
+
const encodedNoteId = encodeURIComponent(noteId);
|
|
27
|
+
|
|
28
|
+
// Navigate for cookie context
|
|
29
|
+
await page.goto('https://creator.xiaohongshu.com/new/home');
|
|
30
|
+
await page.wait(2);
|
|
31
|
+
|
|
32
|
+
const data = await page.evaluate(`
|
|
33
|
+
async () => {
|
|
34
|
+
try {
|
|
35
|
+
const resp = await fetch(
|
|
36
|
+
'/api/galaxy/creator/data/note_detail?note_id=${encodedNoteId}',
|
|
37
|
+
{ credentials: 'include' }
|
|
38
|
+
);
|
|
39
|
+
if (!resp.ok) return { error: 'HTTP ' + resp.status };
|
|
40
|
+
return await resp.json();
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return { error: e.message };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`);
|
|
46
|
+
|
|
47
|
+
if (data?.error) {
|
|
48
|
+
throw new Error(data.error + '. Check note_id and login status.');
|
|
49
|
+
}
|
|
50
|
+
if (!data?.data) {
|
|
51
|
+
throw new Error('Unexpected response structure');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const d = data.data;
|
|
55
|
+
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
channel: 'Total',
|
|
59
|
+
reads: d.total_read ?? 0,
|
|
60
|
+
engagement: d.total_engage ?? 0,
|
|
61
|
+
likes: d.total_like ?? 0,
|
|
62
|
+
collects: d.total_fav ?? 0,
|
|
63
|
+
comments: d.total_cmt ?? 0,
|
|
64
|
+
shares: d.total_share ?? 0,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
channel: 'Organic',
|
|
68
|
+
reads: d.normal_read ?? 0,
|
|
69
|
+
engagement: d.normal_engage ?? 0,
|
|
70
|
+
likes: d.normal_like ?? 0,
|
|
71
|
+
collects: d.normal_fav ?? 0,
|
|
72
|
+
comments: d.normal_cmt ?? 0,
|
|
73
|
+
shares: d.normal_share ?? 0,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
channel: 'Promoted',
|
|
77
|
+
reads: d.total_promo_read ?? 0,
|
|
78
|
+
engagement: 0,
|
|
79
|
+
likes: 0,
|
|
80
|
+
collects: 0,
|
|
81
|
+
comments: 0,
|
|
82
|
+
shares: 0,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
channel: 'Video',
|
|
86
|
+
reads: d.video_read ?? 0,
|
|
87
|
+
engagement: d.video_engage ?? 0,
|
|
88
|
+
likes: d.video_like ?? 0,
|
|
89
|
+
collects: d.video_fav ?? 0,
|
|
90
|
+
comments: d.video_cmt ?? 0,
|
|
91
|
+
shares: d.video_share ?? 0,
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
},
|
|
95
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Xiaohongshu Creator Note List — per-note metrics from the creator backend.
|
|
3
|
+
*
|
|
4
|
+
* Navigates to the note manager page and extracts per-note data from
|
|
5
|
+
* the rendered DOM. This approach bypasses the v2 API signature requirement.
|
|
6
|
+
*
|
|
7
|
+
* Returns: note title, publish date, views, likes, collects, comments.
|
|
8
|
+
*
|
|
9
|
+
* Requires: logged into creator.xiaohongshu.com in Chrome.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { cli, Strategy } from '../../registry.js';
|
|
13
|
+
|
|
14
|
+
cli({
|
|
15
|
+
site: 'xiaohongshu',
|
|
16
|
+
name: 'creator-notes',
|
|
17
|
+
description: '小红书创作者笔记列表 + 每篇数据 (标题/日期/观看/点赞/收藏/评论)',
|
|
18
|
+
domain: 'creator.xiaohongshu.com',
|
|
19
|
+
strategy: Strategy.COOKIE,
|
|
20
|
+
browser: true,
|
|
21
|
+
args: [
|
|
22
|
+
{ name: 'limit', type: 'int', default: 20, help: 'Number of notes to return' },
|
|
23
|
+
],
|
|
24
|
+
columns: ['rank', 'id', 'title', 'date', 'views', 'likes', 'collects', 'comments', 'url'],
|
|
25
|
+
func: async (page, kwargs) => {
|
|
26
|
+
const limit = kwargs.limit || 20;
|
|
27
|
+
|
|
28
|
+
// Navigate to note manager
|
|
29
|
+
await page.goto('https://creator.xiaohongshu.com/new/note-manager');
|
|
30
|
+
await page.wait(4);
|
|
31
|
+
|
|
32
|
+
// Scroll to load more notes if needed
|
|
33
|
+
await page.autoScroll({ times: Math.ceil(limit / 10), delayMs: 1500 });
|
|
34
|
+
|
|
35
|
+
// Extract note data from rendered DOM
|
|
36
|
+
const notes = await page.evaluate(`
|
|
37
|
+
(() => {
|
|
38
|
+
const results = [];
|
|
39
|
+
// Note cards in the manager page contain title, date, and metric numbers
|
|
40
|
+
// Each note card has a consistent structure with the title, date line,
|
|
41
|
+
// and a row of 4 numbers (views, likes, collects, comments)
|
|
42
|
+
const cards = document.querySelectorAll('[class*="note-item"], [class*="noteItem"], [class*="card"]');
|
|
43
|
+
|
|
44
|
+
if (cards.length === 0) {
|
|
45
|
+
// Fallback: parse from any container with note-like content
|
|
46
|
+
const allText = document.body.innerText;
|
|
47
|
+
const notePattern = /(.+?)\\s+发布于\\s+(\\d{4}年\\d{2}月\\d{2}日\\s+\\d{2}:\\d{2})\\s*(\\d+)\\s*(\\d+)\\s*(\\d+)\\s*(\\d+)/g;
|
|
48
|
+
let match;
|
|
49
|
+
while ((match = notePattern.exec(allText)) !== null) {
|
|
50
|
+
results.push({
|
|
51
|
+
title: match[1].trim(),
|
|
52
|
+
date: match[2],
|
|
53
|
+
views: parseInt(match[3]) || 0,
|
|
54
|
+
likes: parseInt(match[4]) || 0,
|
|
55
|
+
collects: parseInt(match[5]) || 0,
|
|
56
|
+
comments: parseInt(match[6]) || 0,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return results;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
cards.forEach(card => {
|
|
63
|
+
const text = card.innerText || '';
|
|
64
|
+
const linkEl = card.querySelector('a[href*="/publish/"], a[href*="/note/"], a[href*="/explore/"]');
|
|
65
|
+
const href = linkEl?.getAttribute('href') || '';
|
|
66
|
+
const idMatch = href.match(/\/(?:publish|explore|note)\/([a-zA-Z0-9]+)/);
|
|
67
|
+
// Try to extract structured data
|
|
68
|
+
const lines = text.split('\\n').map(l => l.trim()).filter(Boolean);
|
|
69
|
+
if (lines.length < 2) return;
|
|
70
|
+
|
|
71
|
+
const title = lines[0];
|
|
72
|
+
const dateLine = lines.find(l => l.includes('发布于'));
|
|
73
|
+
const dateMatch = dateLine?.match(/发布于\\s+(\\d{4}年\\d{2}月\\d{2}日\\s+\\d{2}:\\d{2})/);
|
|
74
|
+
|
|
75
|
+
// Remove the publish timestamp before collecting note metrics.
|
|
76
|
+
// Otherwise year/month/day/hour digits are picked up as views/likes/etc.
|
|
77
|
+
const metricText = dateLine ? text.replace(dateLine, ' ') : text;
|
|
78
|
+
const nums = metricText.match(/(?:^|\\s)(\\d+)(?:\\s|$)/g)?.map(n => parseInt(n.trim())) || [];
|
|
79
|
+
|
|
80
|
+
if (title && !title.includes('全部笔记')) {
|
|
81
|
+
results.push({
|
|
82
|
+
id: idMatch ? idMatch[1] : '',
|
|
83
|
+
title: title.replace(/\\s+/g, ' ').substring(0, 80),
|
|
84
|
+
date: dateMatch ? dateMatch[1] : '',
|
|
85
|
+
views: nums[0] || 0,
|
|
86
|
+
likes: nums[1] || 0,
|
|
87
|
+
collects: nums[2] || 0,
|
|
88
|
+
comments: nums[3] || 0,
|
|
89
|
+
url: href ? new URL(href, window.location.origin).toString() : '',
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return results;
|
|
95
|
+
})()
|
|
96
|
+
`);
|
|
97
|
+
|
|
98
|
+
if (!Array.isArray(notes) || notes.length === 0) {
|
|
99
|
+
throw new Error('No notes found. Are you logged into creator.xiaohongshu.com?');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return notes
|
|
103
|
+
.slice(0, limit)
|
|
104
|
+
.map((n: any, i: number) => ({
|
|
105
|
+
rank: i + 1,
|
|
106
|
+
id: n.id,
|
|
107
|
+
title: n.title,
|
|
108
|
+
date: n.date,
|
|
109
|
+
views: n.views,
|
|
110
|
+
likes: n.likes,
|
|
111
|
+
collects: n.collects,
|
|
112
|
+
comments: n.comments,
|
|
113
|
+
url: n.url,
|
|
114
|
+
}));
|
|
115
|
+
},
|
|
116
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Xiaohongshu Creator Profile — creator account info and growth status.
|
|
3
|
+
*
|
|
4
|
+
* Uses the creator.xiaohongshu.com internal API (cookie auth).
|
|
5
|
+
* Returns follower/following counts, total likes+collects, and
|
|
6
|
+
* creator level growth info.
|
|
7
|
+
*
|
|
8
|
+
* Requires: logged into creator.xiaohongshu.com in Chrome.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { cli, Strategy } from '../../registry.js';
|
|
12
|
+
|
|
13
|
+
cli({
|
|
14
|
+
site: 'xiaohongshu',
|
|
15
|
+
name: 'creator-profile',
|
|
16
|
+
description: '小红书创作者账号信息 (粉丝/关注/获赞/成长等级)',
|
|
17
|
+
domain: 'creator.xiaohongshu.com',
|
|
18
|
+
strategy: Strategy.COOKIE,
|
|
19
|
+
browser: true,
|
|
20
|
+
args: [],
|
|
21
|
+
columns: ['field', 'value'],
|
|
22
|
+
func: async (page, _kwargs) => {
|
|
23
|
+
await page.goto('https://creator.xiaohongshu.com/new/home');
|
|
24
|
+
await page.wait(3);
|
|
25
|
+
|
|
26
|
+
const data = await page.evaluate(`
|
|
27
|
+
async () => {
|
|
28
|
+
try {
|
|
29
|
+
const resp = await fetch('/api/galaxy/creator/home/personal_info', {
|
|
30
|
+
credentials: 'include',
|
|
31
|
+
});
|
|
32
|
+
if (!resp.ok) return { error: 'HTTP ' + resp.status };
|
|
33
|
+
return await resp.json();
|
|
34
|
+
} catch (e) {
|
|
35
|
+
return { error: e.message };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`);
|
|
39
|
+
|
|
40
|
+
if (data?.error) {
|
|
41
|
+
throw new Error(data.error + '. Are you logged into creator.xiaohongshu.com?');
|
|
42
|
+
}
|
|
43
|
+
if (!data?.data) {
|
|
44
|
+
throw new Error('Unexpected response structure');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const d = data.data;
|
|
48
|
+
const grow = d.grow_info || {};
|
|
49
|
+
|
|
50
|
+
return [
|
|
51
|
+
{ field: 'Name', value: d.name ?? '' },
|
|
52
|
+
{ field: 'Followers', value: d.fans_count ?? 0 },
|
|
53
|
+
{ field: 'Following', value: d.follow_count ?? 0 },
|
|
54
|
+
{ field: 'Likes & Collects', value: d.faved_count ?? 0 },
|
|
55
|
+
{ field: 'Creator Level', value: grow.level ?? 0 },
|
|
56
|
+
{ field: 'Level Progress', value: `${grow.fans_count ?? 0}/${grow.max_fans_count ?? 0} fans` },
|
|
57
|
+
{ field: 'Bio', value: (d.personal_desc ?? '').replace(/\\n/g, ' | ') },
|
|
58
|
+
];
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Xiaohongshu Creator Analytics — account-level metrics overview.
|
|
3
|
+
*
|
|
4
|
+
* Uses the creator.xiaohongshu.com internal API (cookie auth).
|
|
5
|
+
* Returns 7-day and 30-day aggregate stats: views, likes, collects,
|
|
6
|
+
* comments, shares, new followers, and daily trend data.
|
|
7
|
+
*
|
|
8
|
+
* Requires: logged into creator.xiaohongshu.com in Chrome.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { cli, Strategy } from '../../registry.js';
|
|
12
|
+
|
|
13
|
+
cli({
|
|
14
|
+
site: 'xiaohongshu',
|
|
15
|
+
name: 'creator-stats',
|
|
16
|
+
description: '小红书创作者数据总览 (观看/点赞/收藏/评论/分享/涨粉,含每日趋势)',
|
|
17
|
+
domain: 'creator.xiaohongshu.com',
|
|
18
|
+
strategy: Strategy.COOKIE,
|
|
19
|
+
browser: true,
|
|
20
|
+
args: [
|
|
21
|
+
{
|
|
22
|
+
name: 'period',
|
|
23
|
+
type: 'string',
|
|
24
|
+
default: 'seven',
|
|
25
|
+
help: 'Stats period: seven or thirty',
|
|
26
|
+
choices: ['seven', 'thirty'],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
columns: ['metric', 'total', 'trend'],
|
|
30
|
+
func: async (page, kwargs) => {
|
|
31
|
+
const period: string = kwargs.period || 'seven';
|
|
32
|
+
|
|
33
|
+
// Navigate to creator center for cookie context
|
|
34
|
+
await page.goto('https://creator.xiaohongshu.com/new/home');
|
|
35
|
+
await page.wait(3);
|
|
36
|
+
|
|
37
|
+
const data = await page.evaluate(`
|
|
38
|
+
async () => {
|
|
39
|
+
try {
|
|
40
|
+
const resp = await fetch('/api/galaxy/creator/data/note_detail_new', {
|
|
41
|
+
credentials: 'include',
|
|
42
|
+
});
|
|
43
|
+
if (!resp.ok) return { error: 'HTTP ' + resp.status };
|
|
44
|
+
return await resp.json();
|
|
45
|
+
} catch (e) {
|
|
46
|
+
return { error: e.message };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`);
|
|
50
|
+
|
|
51
|
+
if (data?.error) {
|
|
52
|
+
throw new Error(data.error + '. Are you logged into creator.xiaohongshu.com?');
|
|
53
|
+
}
|
|
54
|
+
if (!data?.data) {
|
|
55
|
+
throw new Error('Unexpected response structure');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const stats = data.data[period];
|
|
59
|
+
if (!stats) {
|
|
60
|
+
throw new Error(`No data for period "${period}". Available: ${Object.keys(data.data).join(', ')}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Format daily trend as sparkline-like summary
|
|
64
|
+
const formatTrend = (list: any[]): string => {
|
|
65
|
+
if (!list || !list.length) return '-';
|
|
66
|
+
return list.map((d: any) => d.count).join(' → ');
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return [
|
|
70
|
+
{ metric: '观看数 (views)', total: stats.view_count ?? 0, trend: formatTrend(stats.view_list) },
|
|
71
|
+
{ metric: '平均观看时长 (avg view time ms)', total: stats.view_time_avg ?? 0, trend: formatTrend(stats.view_time_list) },
|
|
72
|
+
{ metric: '主页访问 (home views)', total: stats.home_view_count ?? 0, trend: formatTrend(stats.home_view_list) },
|
|
73
|
+
{ metric: '点赞数 (likes)', total: stats.like_count ?? 0, trend: formatTrend(stats.like_list) },
|
|
74
|
+
{ metric: '收藏数 (collects)', total: stats.collect_count ?? 0, trend: formatTrend(stats.collect_list) },
|
|
75
|
+
{ metric: '评论数 (comments)', total: stats.comment_count ?? 0, trend: formatTrend(stats.comment_list) },
|
|
76
|
+
{ metric: '弹幕数 (danmaku)', total: stats.danmaku_count ?? 0, trend: '-' },
|
|
77
|
+
{ metric: '分享数 (shares)', total: stats.share_count ?? 0, trend: formatTrend(stats.share_list) },
|
|
78
|
+
{ metric: '涨粉数 (new followers)', total: stats.rise_fans_count ?? 0, trend: formatTrend(stats.rise_fans_list) },
|
|
79
|
+
];
|
|
80
|
+
},
|
|
81
|
+
});
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Xiaohongshu download — download images and videos from a note.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* opencli xiaohongshu download --note-id abc123 --output ./xhs
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as fs from 'node:fs';
|
|
9
|
+
import * as path from 'node:path';
|
|
10
|
+
import { cli, Strategy } from '../../registry.js';
|
|
11
|
+
import {
|
|
12
|
+
httpDownload,
|
|
13
|
+
sanitizeFilename,
|
|
14
|
+
detectContentType,
|
|
15
|
+
} from '../../download/index.js';
|
|
16
|
+
import { DownloadProgressTracker, formatBytes } from '../../download/progress.js';
|
|
17
|
+
|
|
18
|
+
cli({
|
|
19
|
+
site: 'xiaohongshu',
|
|
20
|
+
name: 'download',
|
|
21
|
+
description: '下载小红书笔记中的图片和视频',
|
|
22
|
+
domain: 'www.xiaohongshu.com',
|
|
23
|
+
strategy: Strategy.COOKIE,
|
|
24
|
+
args: [
|
|
25
|
+
{ name: 'note_id', required: true, help: 'Note ID (from URL)' },
|
|
26
|
+
{ name: 'output', default: './xiaohongshu-downloads', help: 'Output directory' },
|
|
27
|
+
],
|
|
28
|
+
columns: ['index', 'type', 'status', 'size'],
|
|
29
|
+
func: async (page, kwargs) => {
|
|
30
|
+
const noteId = kwargs.note_id;
|
|
31
|
+
const output = kwargs.output;
|
|
32
|
+
|
|
33
|
+
// Navigate to note page
|
|
34
|
+
await page.goto(`https://www.xiaohongshu.com/explore/${noteId}`);
|
|
35
|
+
await page.wait(3);
|
|
36
|
+
|
|
37
|
+
// Extract note info and media URLs
|
|
38
|
+
const data = await page.evaluate(`
|
|
39
|
+
(() => {
|
|
40
|
+
const result = {
|
|
41
|
+
noteId: '${noteId}',
|
|
42
|
+
title: '',
|
|
43
|
+
author: '',
|
|
44
|
+
media: []
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Get title
|
|
48
|
+
const titleEl = document.querySelector('.title, #detail-title, .note-content .title');
|
|
49
|
+
result.title = titleEl?.textContent?.trim() || 'untitled';
|
|
50
|
+
|
|
51
|
+
// Get author
|
|
52
|
+
const authorEl = document.querySelector('.username, .author-name, .name');
|
|
53
|
+
result.author = authorEl?.textContent?.trim() || 'unknown';
|
|
54
|
+
|
|
55
|
+
// Get images - try multiple selectors
|
|
56
|
+
const imageSelectors = [
|
|
57
|
+
'.swiper-slide img',
|
|
58
|
+
'.carousel-image img',
|
|
59
|
+
'.note-slider img',
|
|
60
|
+
'.note-image img',
|
|
61
|
+
'.image-wrapper img',
|
|
62
|
+
'#noteContainer img[src*="xhscdn"]',
|
|
63
|
+
'img[src*="ci.xiaohongshu.com"]'
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
const imageUrls = new Set();
|
|
67
|
+
for (const selector of imageSelectors) {
|
|
68
|
+
document.querySelectorAll(selector).forEach(img => {
|
|
69
|
+
let src = img.src || img.getAttribute('data-src') || '';
|
|
70
|
+
if (src && (src.includes('xhscdn') || src.includes('xiaohongshu'))) {
|
|
71
|
+
// Convert to high quality URL (remove resize parameters)
|
|
72
|
+
src = src.split('?')[0];
|
|
73
|
+
// Try to get original size
|
|
74
|
+
src = src.replace(/\\/imageView\\d+\\/\\d+\\/w\\/\\d+/, '');
|
|
75
|
+
imageUrls.add(src);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Get video if exists
|
|
81
|
+
const videoSelectors = [
|
|
82
|
+
'video source',
|
|
83
|
+
'video[src]',
|
|
84
|
+
'.player video',
|
|
85
|
+
'.video-player video'
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
for (const selector of videoSelectors) {
|
|
89
|
+
document.querySelectorAll(selector).forEach(v => {
|
|
90
|
+
const src = v.src || v.getAttribute('src') || '';
|
|
91
|
+
if (src) {
|
|
92
|
+
result.media.push({
|
|
93
|
+
type: 'video',
|
|
94
|
+
url: src
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Add images to media
|
|
101
|
+
imageUrls.forEach(url => {
|
|
102
|
+
result.media.push({
|
|
103
|
+
type: 'image',
|
|
104
|
+
url: url
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return result;
|
|
109
|
+
})()
|
|
110
|
+
`);
|
|
111
|
+
|
|
112
|
+
if (!data || !data.media || data.media.length === 0) {
|
|
113
|
+
return [{ index: 0, type: '-', status: 'failed', size: 'No media found' }];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Extract cookies for authenticated downloads
|
|
117
|
+
const cookies = await page.evaluate(`(() => document.cookie)()`);
|
|
118
|
+
|
|
119
|
+
// Create output directory
|
|
120
|
+
const outputDir = path.join(output, noteId);
|
|
121
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
122
|
+
|
|
123
|
+
// Download all media files
|
|
124
|
+
const tracker = new DownloadProgressTracker(data.media.length, true);
|
|
125
|
+
const results: any[] = [];
|
|
126
|
+
|
|
127
|
+
for (let i = 0; i < data.media.length; i++) {
|
|
128
|
+
const media = data.media[i];
|
|
129
|
+
const ext = media.type === 'video' ? 'mp4' : 'jpg';
|
|
130
|
+
const filename = `${noteId}_${i + 1}.${ext}`;
|
|
131
|
+
const destPath = path.join(outputDir, filename);
|
|
132
|
+
|
|
133
|
+
const progressBar = tracker.onFileStart(filename, i);
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
const result = await httpDownload(media.url, destPath, {
|
|
137
|
+
cookies: typeof cookies === 'string' ? cookies : '',
|
|
138
|
+
timeout: 60000,
|
|
139
|
+
onProgress: (received, total) => {
|
|
140
|
+
if (progressBar) progressBar.update(received, total);
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
if (progressBar) {
|
|
145
|
+
progressBar.complete(result.success, result.success ? formatBytes(result.size) : undefined);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
tracker.onFileComplete(result.success);
|
|
149
|
+
|
|
150
|
+
results.push({
|
|
151
|
+
index: i + 1,
|
|
152
|
+
type: media.type,
|
|
153
|
+
status: result.success ? 'success' : 'failed',
|
|
154
|
+
size: result.success ? formatBytes(result.size) : (result.error || 'unknown error'),
|
|
155
|
+
});
|
|
156
|
+
} catch (err: any) {
|
|
157
|
+
if (progressBar) progressBar.fail(err.message);
|
|
158
|
+
tracker.onFileComplete(false);
|
|
159
|
+
|
|
160
|
+
results.push({
|
|
161
|
+
index: i + 1,
|
|
162
|
+
type: media.type,
|
|
163
|
+
status: 'failed',
|
|
164
|
+
size: err.message,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
tracker.finish();
|
|
170
|
+
|
|
171
|
+
return results;
|
|
172
|
+
},
|
|
173
|
+
});
|
|
@@ -43,7 +43,7 @@ cli({
|
|
|
43
43
|
const linkEl = el.querySelector('a[href*="/explore/"], a[href*="/search_result/"], a[href*="/note/"]');
|
|
44
44
|
|
|
45
45
|
const href = linkEl?.getAttribute('href') || '';
|
|
46
|
-
const noteId = href.match(/\\/(?:explore|note)\\/([a-
|
|
46
|
+
const noteId = href.match(/\\/(?:explore|note)\\/([a-zA-Z0-9]+)/)?.[1] || '';
|
|
47
47
|
|
|
48
48
|
results.push({
|
|
49
49
|
title: (titleEl?.textContent || '').trim(),
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
buildXhsNoteUrl,
|
|
4
|
+
extractXhsUserNotes,
|
|
5
|
+
flattenXhsNoteGroups,
|
|
6
|
+
normalizeXhsUserId,
|
|
7
|
+
} from './user-helpers.js';
|
|
8
|
+
|
|
9
|
+
describe('normalizeXhsUserId', () => {
|
|
10
|
+
it('extracts the profile id from a full Xiaohongshu URL', () => {
|
|
11
|
+
expect(
|
|
12
|
+
normalizeXhsUserId(
|
|
13
|
+
'https://www.xiaohongshu.com/user/profile/615529370000000002026001?xsec_source=pc_search'
|
|
14
|
+
)
|
|
15
|
+
).toBe('615529370000000002026001');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('keeps a bare profile id unchanged', () => {
|
|
19
|
+
expect(normalizeXhsUserId('615529370000000002026001')).toBe('615529370000000002026001');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('flattenXhsNoteGroups', () => {
|
|
24
|
+
it('flattens grouped note arrays and ignores empty groups', () => {
|
|
25
|
+
expect(flattenXhsNoteGroups([[{ id: 'a' }], [], null, [{ id: 'b' }]])).toEqual([
|
|
26
|
+
{ id: 'a' },
|
|
27
|
+
{ id: 'b' },
|
|
28
|
+
]);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('buildXhsNoteUrl', () => {
|
|
33
|
+
it('includes xsec token when available', () => {
|
|
34
|
+
expect(buildXhsNoteUrl('user123', 'note456', 'token789')).toBe(
|
|
35
|
+
'https://www.xiaohongshu.com/user/profile/user123/note456?xsec_token=token789&xsec_source=pc_user'
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('extractXhsUserNotes', () => {
|
|
41
|
+
it('normalizes grouped note cards into CLI rows', () => {
|
|
42
|
+
const rows = extractXhsUserNotes(
|
|
43
|
+
{
|
|
44
|
+
noteGroups: [
|
|
45
|
+
[
|
|
46
|
+
{
|
|
47
|
+
id: 'note-1',
|
|
48
|
+
xsecToken: 'abc',
|
|
49
|
+
noteCard: {
|
|
50
|
+
noteId: 'note-1',
|
|
51
|
+
displayTitle: 'First note',
|
|
52
|
+
type: 'video',
|
|
53
|
+
interactInfo: { likedCount: '4.6万' },
|
|
54
|
+
user: { userId: 'user-1' },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
noteCard: {
|
|
59
|
+
note_id: 'note-2',
|
|
60
|
+
display_title: 'Second note',
|
|
61
|
+
type: 'normal',
|
|
62
|
+
interact_info: { liked_count: 42 },
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
[],
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
'fallback-user'
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
expect(rows).toEqual([
|
|
73
|
+
{
|
|
74
|
+
id: 'note-1',
|
|
75
|
+
title: 'First note',
|
|
76
|
+
type: 'video',
|
|
77
|
+
likes: '4.6万',
|
|
78
|
+
url: 'https://www.xiaohongshu.com/user/profile/user-1/note-1?xsec_token=abc&xsec_source=pc_user',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'note-2',
|
|
82
|
+
title: 'Second note',
|
|
83
|
+
type: 'normal',
|
|
84
|
+
likes: '42',
|
|
85
|
+
url: 'https://www.xiaohongshu.com/user/profile/fallback-user/note-2',
|
|
86
|
+
},
|
|
87
|
+
]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('deduplicates repeated notes by note id', () => {
|
|
91
|
+
const rows = extractXhsUserNotes(
|
|
92
|
+
{
|
|
93
|
+
noteGroups: [
|
|
94
|
+
[
|
|
95
|
+
{ noteCard: { noteId: 'dup-1', displayTitle: 'keep me' } },
|
|
96
|
+
{ noteCard: { noteId: 'dup-1', displayTitle: 'drop me' } },
|
|
97
|
+
],
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
'fallback-user'
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
expect(rows).toHaveLength(1);
|
|
104
|
+
expect(rows[0]?.title).toBe('keep me');
|
|
105
|
+
});
|
|
106
|
+
});
|