小红书重构
1. 图文上传 2. 视频上传(封面,定时) 3. cli 4. skill 5. 无头模式
This commit is contained in:
+30
-11
@@ -4,6 +4,7 @@
|
||||
|
||||
- `douyin`
|
||||
- `kuaishou`
|
||||
- `xiaohongshu`
|
||||
- `bilibili`
|
||||
|
||||
实现说明:
|
||||
@@ -13,6 +14,7 @@
|
||||
- 如果需要给 OpenClaw、Codex 等 agent 使用,可参考仓库内 skill:
|
||||
- `skills/douyin-upload/`
|
||||
- `skills/kuaishou-upload/`
|
||||
- `skills/xiaohongshu-upload/`
|
||||
- `skills/bilibili-upload/`
|
||||
|
||||
## 安装 CLI 入口
|
||||
@@ -28,6 +30,7 @@ uv pip install -e .
|
||||
```bash
|
||||
sau douyin --help
|
||||
sau kuaishou --help
|
||||
sau xiaohongshu --help
|
||||
sau bilibili --help
|
||||
```
|
||||
|
||||
@@ -45,8 +48,8 @@ $env:PLAYWRIGHT_DOWNLOAD_HOST="https://npmmirror.com/mirrors/playwright"; patchr
|
||||
sau douyin login --account <account_name>
|
||||
sau douyin login --account <account_name> --headless
|
||||
sau douyin check --account <account_name>
|
||||
sau douyin upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --tags 运动,训练
|
||||
sau douyin upload-note --account <account_name> --images videos/1.png videos/2.png --note "图文示例" --tags 图文,测试
|
||||
sau douyin upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --tags 运动,训练
|
||||
sau douyin upload-note --account <account_name> --images videos/1.png videos/2.png --title "图文标题" --note "图文示例" --tags 图文,测试
|
||||
```
|
||||
|
||||
## 快手 CLI 子命令
|
||||
@@ -54,8 +57,17 @@ sau douyin upload-note --account <account_name> --images videos/1.png videos/2.p
|
||||
```bash
|
||||
sau kuaishou login --account <account_name>
|
||||
sau kuaishou check --account <account_name>
|
||||
sau kuaishou upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --tags 运动,训练
|
||||
sau kuaishou upload-note --account <account_name> --images videos/1.png videos/2.png videos/3.png --note "图文示例" --tags 图文,测试
|
||||
sau kuaishou upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --tags 运动,训练
|
||||
sau kuaishou upload-note --account <account_name> --images videos/1.png videos/2.png videos/3.png --title "图文标题" --note "图文示例" --tags 图文,测试
|
||||
```
|
||||
|
||||
## 小红书 CLI 子命令
|
||||
|
||||
```bash
|
||||
sau xiaohongshu login --account <account_name>
|
||||
sau xiaohongshu check --account <account_name>
|
||||
sau xiaohongshu upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --tags 小红书,视频
|
||||
sau xiaohongshu upload-note --account <account_name> --images videos/1.png videos/2.png videos/3.png --title "图文标题" --note "图文示例" --tags 图文,测试
|
||||
```
|
||||
|
||||
## Bilibili CLI 子命令
|
||||
@@ -70,6 +82,9 @@ sau bilibili upload-video --account <account_name> --file videos/demo.mp4 --titl
|
||||
|
||||
- `creator` 之类的名字只是示例值,真正传的是用户自定义的 `account_name`
|
||||
- 一个 `account_name` 对应一个账号文件,可以准备多个账号并发使用
|
||||
- 浏览器平台统一元数据约定:
|
||||
- 视频使用 `title + desc + tags`
|
||||
- 图文使用 `title + note + tags`
|
||||
- `sau bilibili ...` 会自动准备 `biliup`
|
||||
- 如果本地没有 `biliup`,第一次运行会自动下载
|
||||
- 如果上游 GitHub Release 有更新,运行时会先自动更新
|
||||
@@ -77,7 +92,7 @@ sau bilibili upload-video --account <account_name> --file videos/demo.mp4 --titl
|
||||
|
||||
## 登录二维码说明
|
||||
|
||||
- 抖音和快手登录过程中,CLI / uploader 可能会生成临时二维码图片
|
||||
- 抖音、快手、小红书登录过程中,CLI / uploader 可能会生成临时二维码图片
|
||||
- 对普通用户来说,可以直接打开该图片扫码
|
||||
- 对可操作本地文件的 agent 来说,不要只把图片路径告诉用户
|
||||
- 这类二维码图片本身就是给用户扫码的,agent 应优先直接展示/发送本地图片给用户
|
||||
@@ -85,13 +100,15 @@ sau bilibili upload-video --account <account_name> --file videos/demo.mp4 --titl
|
||||
|
||||
## 定时发布
|
||||
|
||||
抖音、快手、Bilibili 的视频上传都支持 `--schedule`。只要传了 `--schedule`,CLI 就会自动切换到对应平台的定时发布策略;不传则默认立即发布。
|
||||
抖音、快手、小红书的图文和视频上传,以及 Bilibili 的视频上传都支持 `--schedule`。只要传了 `--schedule`,CLI 就会自动切换到对应平台的定时发布策略;不传则默认立即发布。
|
||||
|
||||
```bash
|
||||
sau douyin upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --schedule "2026-03-24 21:30"
|
||||
sau douyin upload-note --account <account_name> --images videos/1.png videos/2.png --note "图文示例" --schedule "2026-03-24 21:30"
|
||||
sau kuaishou upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --schedule "2026-03-24 21:30"
|
||||
sau kuaishou upload-note --account <account_name> --images videos/1.png videos/2.png videos/3.png --note "图文示例" --schedule "2026-03-24 21:30"
|
||||
sau douyin upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --schedule "2026-03-24 21:30"
|
||||
sau douyin upload-note --account <account_name> --images videos/1.png videos/2.png --title "图文标题" --note "图文示例" --schedule "2026-03-24 21:30"
|
||||
sau kuaishou upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --schedule "2026-03-24 21:30"
|
||||
sau kuaishou upload-note --account <account_name> --images videos/1.png videos/2.png videos/3.png --title "图文标题" --note "图文示例" --schedule "2026-03-24 21:30"
|
||||
sau xiaohongshu upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --schedule "2026-03-24 21:30"
|
||||
sau xiaohongshu upload-note --account <account_name> --images videos/1.png videos/2.png videos/3.png --title "图文标题" --note "图文示例" --schedule "2026-03-24 21:30"
|
||||
sau bilibili upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --tid 249 --schedule "2026-03-24 21:30"
|
||||
```
|
||||
|
||||
@@ -121,6 +138,7 @@ CLI 将 `debug` 和 `headless` 拆成了两个独立维度:
|
||||
```bash
|
||||
--file videos/demo.mp4
|
||||
--title "示例标题"
|
||||
--desc "示例简介"
|
||||
--tags 运动,训练
|
||||
--thumbnail videos/demo.png
|
||||
```
|
||||
@@ -135,7 +153,6 @@ CLI 将 `debug` 和 `headless` 拆成了两个独立维度:
|
||||
Bilibili 额外要求:
|
||||
|
||||
```bash
|
||||
--desc "视频简介"
|
||||
--tid 249
|
||||
```
|
||||
|
||||
@@ -147,6 +164,7 @@ Bilibili 额外要求:
|
||||
|
||||
```bash
|
||||
--images videos/1.png videos/2.png videos/3.png
|
||||
--title "图文标题"
|
||||
--note "图文内容"
|
||||
--tags 图文,测试
|
||||
```
|
||||
@@ -155,5 +173,6 @@ Bilibili 额外要求:
|
||||
|
||||
- 抖音:最多 35 张图片,不支持 GIF
|
||||
- 快手:支持多张图片,建议传真实不同文件,不要把同一路径重复多次
|
||||
- 小红书:支持多张图片,正文 `--note` 可选,但 `--title` 建议始终显式传入
|
||||
|
||||
后续维护 CLI 时,优先看 `sau_cli.py`、`uploader/` 和 `skills/`。
|
||||
|
||||
+26
-4
@@ -84,6 +84,7 @@ Windows 也可以直接手动复制并重命名。
|
||||
sau --help
|
||||
sau douyin --help
|
||||
sau kuaishou --help
|
||||
sau xiaohongshu --help
|
||||
sau bilibili --help
|
||||
```
|
||||
|
||||
@@ -97,7 +98,8 @@ sau bilibili --help
|
||||
```bash
|
||||
sau douyin login --account <account_name>
|
||||
sau douyin check --account <account_name>
|
||||
sau douyin upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题"
|
||||
sau douyin upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介"
|
||||
sau douyin upload-note --account <account_name> --images videos/1.png videos/2.png --title "图文标题" --note "图文正文"
|
||||
```
|
||||
|
||||
### 8. 快手主线示例
|
||||
@@ -105,11 +107,20 @@ sau douyin upload-video --account <account_name> --file videos/demo.mp4 --title
|
||||
```bash
|
||||
sau kuaishou login --account <account_name>
|
||||
sau kuaishou check --account <account_name>
|
||||
sau kuaishou upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题"
|
||||
sau kuaishou upload-note --account <account_name> --images videos/1.png videos/2.png videos/3.png --note "图文示例"
|
||||
sau kuaishou upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介"
|
||||
sau kuaishou upload-note --account <account_name> --images videos/1.png videos/2.png videos/3.png --title "图文标题" --note "图文正文"
|
||||
```
|
||||
|
||||
### 9. Bilibili 主线示例
|
||||
### 9. 小红书主线示例
|
||||
|
||||
```bash
|
||||
sau xiaohongshu login --account <account_name>
|
||||
sau xiaohongshu check --account <account_name>
|
||||
sau xiaohongshu upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介"
|
||||
sau xiaohongshu upload-note --account <account_name> --images videos/1.png videos/2.png videos/3.png --title "图文标题" --note "图文正文"
|
||||
```
|
||||
|
||||
### 10. Bilibili 主线示例
|
||||
|
||||
```bash
|
||||
sau bilibili login --account <account_name>
|
||||
@@ -121,6 +132,9 @@ sau bilibili upload-video --account <account_name> --file videos/demo.mp4 --titl
|
||||
|
||||
- `creator` 之类的名字只是示例值,真正传的是用户自定义的 `account_name`
|
||||
- 一个 `account_name` 对应一个账号文件,可以准备多个账号并发使用
|
||||
- 浏览器平台统一元数据约定:
|
||||
- 视频使用 `title + desc + tags`
|
||||
- 图文使用 `title + note + tags`
|
||||
- 用户不需要手动安装 `biliup`
|
||||
- 首次运行 Bilibili 相关命令时,程序会自动下载 `biliup`
|
||||
- 后续运行会自动检查上游 release 并自动更新
|
||||
@@ -161,6 +175,7 @@ PLAYWRIGHT_DOWNLOAD_HOST="https://npmmirror.com/mirrors/playwright" patchright i
|
||||
sau --help
|
||||
sau douyin --help
|
||||
sau kuaishou --help
|
||||
sau xiaohongshu --help
|
||||
sau bilibili --help
|
||||
```
|
||||
|
||||
@@ -177,6 +192,11 @@ sau kuaishou check
|
||||
sau kuaishou upload-video
|
||||
sau kuaishou upload-note
|
||||
|
||||
sau xiaohongshu login
|
||||
sau xiaohongshu check
|
||||
sau xiaohongshu upload-video
|
||||
sau xiaohongshu upload-note
|
||||
|
||||
sau bilibili login
|
||||
sau bilibili check
|
||||
sau bilibili upload-video
|
||||
@@ -188,6 +208,8 @@ sau bilibili upload-video
|
||||
- `skills/douyin-upload/references/cli-contract.md`
|
||||
- `skills/kuaishou-upload/SKILL.md`
|
||||
- `skills/kuaishou-upload/references/cli-contract.md`
|
||||
- `skills/xiaohongshu-upload/SKILL.md`
|
||||
- `skills/xiaohongshu-upload/references/cli-contract.md`
|
||||
- `skills/bilibili-upload/SKILL.md`
|
||||
- `skills/bilibili-upload/references/cli-contract.md`
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Xiaohongshu Shallow Alignment Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Align the browser-based Xiaohongshu uploader with the current Douyin/Kuaishou style for login QR flow, patchright usage, and formal video/note entry points without expanding into CLI or docs work.
|
||||
|
||||
**Architecture:** Keep the work inside `uploader/xiaohongshu_uploader/main.py` as a shallow refactor. Introduce a thin login flow with QR extraction, cookie validation, and result payloads, then add a shared base uploader plus separate video and note browser flows that reuse common setup.
|
||||
|
||||
**Tech Stack:** Python, patchright, async Playwright-compatible browser automation, unittest
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Lock expected login/setup behavior
|
||||
|
||||
**Files:**
|
||||
- Create: `tests/test_xiaohongshu_uploader.py`
|
||||
- Modify: `uploader/xiaohongshu_uploader/main.py`
|
||||
|
||||
- [ ] Add tests for `xiaohongshu_setup(..., return_detail=True)` invalid-cookie behavior and uploader validation behavior.
|
||||
- [ ] Run the targeted test file and confirm it fails for the expected missing behavior.
|
||||
- [ ] Implement the minimal production changes to satisfy those tests.
|
||||
|
||||
### Task 2: Refactor Xiaohongshu uploader module
|
||||
|
||||
**Files:**
|
||||
- Modify: `uploader/xiaohongshu_uploader/main.py`
|
||||
|
||||
- [ ] Switch the module from `playwright.async_api` to `patchright.async_api`.
|
||||
- [ ] Replace `page.pause()` login with QR extraction, terminal printing, QR file saving, polling, and cookie persistence.
|
||||
- [ ] Add a shared base uploader plus formal video and note entry points while keeping legacy public names callable.
|
||||
|
||||
### Task 3: Refresh local debug examples
|
||||
|
||||
**Files:**
|
||||
- Modify: `examples/get_xiaohongshu_cookie.py`
|
||||
- Modify: `examples/upload_video_to_xiaohongshu.py`
|
||||
|
||||
- [ ] Update the login example to use the aligned setup entry.
|
||||
- [ ] Update the upload example to expose direct video/note debug functions.
|
||||
|
||||
### Task 4: Verify
|
||||
|
||||
**Files:**
|
||||
- Test: `tests/test_xiaohongshu_uploader.py`
|
||||
|
||||
- [ ] Run the targeted unittest file.
|
||||
- [ ] Run a quick Python syntax/import check for the modified uploader and examples.
|
||||
+9
-1
@@ -47,9 +47,11 @@ PLAYWRIGHT_DOWNLOAD_HOST="https://npmmirror.com/mirrors/playwright" patchright i
|
||||
sau --help
|
||||
sau douyin --help
|
||||
sau kuaishou --help
|
||||
sau xiaohongshu --help
|
||||
sau bilibili --help
|
||||
sau douyin check --account your_account
|
||||
sau kuaishou check --account your_account
|
||||
sau xiaohongshu check --account your_account
|
||||
sau bilibili check --account your_account
|
||||
```
|
||||
|
||||
@@ -57,6 +59,7 @@ sau bilibili check --account your_account
|
||||
|
||||
- `skills/douyin-upload/SKILL.md`
|
||||
- `skills/kuaishou-upload/SKILL.md`
|
||||
- `skills/xiaohongshu-upload/SKILL.md`
|
||||
- `skills/bilibili-upload/SKILL.md`
|
||||
- `docs/CLI.md`
|
||||
|
||||
@@ -84,14 +87,16 @@ uv pip install -e .
|
||||
sau --help
|
||||
sau douyin --help
|
||||
sau kuaishou --help
|
||||
sau xiaohongshu --help
|
||||
sau bilibili --help
|
||||
```
|
||||
|
||||
5. 如果任务是抖音或快手链路,再继续验证:
|
||||
5. 如果任务是浏览器平台链路,再继续验证:
|
||||
|
||||
```bash
|
||||
sau douyin check --account test
|
||||
sau kuaishou check --account test
|
||||
sau xiaohongshu check --account test
|
||||
sau bilibili check --account test
|
||||
```
|
||||
|
||||
@@ -103,6 +108,9 @@ sau bilibili check --account test
|
||||
- `skills/kuaishou-upload/SKILL.md`
|
||||
- `skills/kuaishou-upload/references/cli-contract.md`
|
||||
- `skills/kuaishou-upload/references/runtime-requirements.md`
|
||||
- `skills/xiaohongshu-upload/SKILL.md`
|
||||
- `skills/xiaohongshu-upload/references/cli-contract.md`
|
||||
- `skills/xiaohongshu-upload/references/runtime-requirements.md`
|
||||
- `skills/bilibili-upload/SKILL.md`
|
||||
- `skills/bilibili-upload/references/cli-contract.md`
|
||||
- `skills/bilibili-upload/references/runtime-requirements.md`
|
||||
|
||||
Reference in New Issue
Block a user