返回 Social Auto Upload
CLI.md
根目录 / docs / CLI.md
1 # CLI 使用说明
2
3 项目现在提供一个统一的 CLI 入口 `sau`,当前主线已经接入:
4
5 - `douyin`
6 - `kuaishou`
7 - `xiaohongshu`
8 - `bilibili`
9
10 实现说明:
11
12 - `sau_cli.py` 是当前 CLI 的主入口和唯一主要实现文件
13 - `sau.exe` 是安装后在 Windows 虚拟环境里自动生成的命令入口,本质上还是调用 `sau_cli.py`
14 - 如果需要给 OpenClaw、Codex 等 agent 使用,可参考仓库内 skill:
15 - `skills/douyin-upload/`
16 - `skills/kuaishou-upload/`
17 - `skills/xiaohongshu-upload/`
18 - `skills/bilibili-upload/`
19
20 ## 安装 CLI 入口
21
22 如果你希望直接使用 `sau` 命令,而不是手动执行 `python sau_cli.py`,先在项目根目录安装一次:
23
24 ```bash
25 uv pip install -e .
26 ```
27
28 安装后就可以直接使用:
29
30 ```bash
31 sau douyin --help
32 sau kuaishou --help
33 sau xiaohongshu --help
34 sau bilibili --help
35 ```
36
37 ## 安装 patchright 浏览器
38
39 Windows 下推荐先指定镜像,再安装 Chromium:
40
41 ```powershell
42 $env:PLAYWRIGHT_DOWNLOAD_HOST="https://npmmirror.com/mirrors/playwright"; patchright install chromium
43 ```
44
45 ## 抖音 CLI 子命令
46
47 ```bash
48 sau douyin login --account <account_name>
49 sau douyin login --account <account_name> --headless
50 sau douyin check --account <account_name>
51 sau douyin upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --tags 运动,训练
52 sau douyin upload-note --account <account_name> --images videos/1.png videos/2.png --title "图文标题" --note "图文示例" --tags 图文,测试
53 ```
54
55 抖音短信验证码补充说明:
56
57 - 视频发布过程中如果触发短信二次验证,CLI 会优先读取项目根目录下的 `verify_code.txt`
58 - 如果未找到 `verify_code.txt`,并且当前命令是在交互式终端中手动运行,CLI 会直接在终端提示输入验证码
59 - 对 agent、自动任务、远程桥接这类场景,仍然可以继续用写入 `verify_code.txt` 的方式喂验证码
60 - 验证通过后,程序会自动清理 `verify_code.txt`
61
62 ## 快手 CLI 子命令
63
64 ```bash
65 sau kuaishou login --account <account_name>
66 sau kuaishou check --account <account_name>
67 sau kuaishou upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --tags 运动,训练
68 sau kuaishou upload-note --account <account_name> --images videos/1.png videos/2.png videos/3.png --title "图文标题" --note "图文示例" --tags 图文,测试
69 ```
70
71 ## 小红书 CLI 子命令
72
73 ```bash
74 sau xiaohongshu login --account <account_name>
75 sau xiaohongshu check --account <account_name>
76 sau xiaohongshu upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --tags 小红书,视频
77 sau xiaohongshu upload-note --account <account_name> --images videos/1.png videos/2.png videos/3.png --title "图文标题" --note "图文示例" --tags 图文,测试
78 ```
79
80 海外环境如果无法登录默认创作者后台,可以通过环境变量切换到 RedNote 域名。该设置同时作用于登录、cookie 校验、视频发布和图文发布:
81
82 ```bash
83 SAU_XHS_CREATOR_BASE_URL=https://creator.rednote.com sau xiaohongshu login --account <account_name>
84 ```
85
86 ## Bilibili CLI 子命令
87
88 ```bash
89 sau bilibili login --account <account_name>
90 sau bilibili check --account <account_name>
91 sau bilibili upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --tid 249 --tags 足球,测试 --thumbnail covers/demo.png
92 ```
93
94 补充说明:
95
96 - `creator` 之类的名字只是示例值,真正传的是用户自定义的 `account_name`
97 - 一个 `account_name` 对应一个账号文件,可以准备多个账号并发使用
98 - 浏览器平台统一元数据约定:
99 - 视频使用 `title + desc + tags`
100 - 图文使用 `title + note + tags`
101 - `sau bilibili ...` 会自动准备 `biliup`
102 - 如果本地没有 `biliup`,第一次运行会自动下载
103 - 如果上游 GitHub Release 有更新,运行时会先自动更新
104 - `sau bilibili login --account <name>` 建议由用户自己在本地真实终端里执行;如果终端里的二维码显示不完整,可直接打开当前目录下的 `qrcode.png` 扫码
105
106 ## 登录二维码说明
107
108 - 抖音、快手、小红书登录过程中,CLI / uploader 可能会生成临时二维码图片
109 - 对普通用户来说,可以直接打开该图片扫码
110 - 对可操作本地文件的 agent 来说,不要只把图片路径告诉用户
111 - 这类二维码图片本身就是给用户扫码的,agent 应优先直接展示/发送本地图片给用户
112 - Bilibili 当前不走这套本地二维码图片托管链路,登录按上面的 Bilibili CLI 说明处理即可
113
114 ## 定时发布
115
116 抖音、快手、小红书的图文和视频上传,以及 Bilibili 的视频上传都支持 `--schedule`。只要传了 `--schedule`,CLI 就会自动切换到对应平台的定时发布策略;不传则默认立即发布。
117
118 ```bash
119 sau douyin upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --schedule "2026-03-24 21:30"
120 sau douyin upload-note --account <account_name> --images videos/1.png videos/2.png --title "图文标题" --note "图文示例" --schedule "2026-03-24 21:30"
121 sau kuaishou upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --schedule "2026-03-24 21:30"
122 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"
123 sau xiaohongshu upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --schedule "2026-03-24 21:30"
124 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"
125 sau bilibili upload-video --account <account_name> --file videos/demo.mp4 --title "示例标题" --desc "示例简介" --tid 249 --schedule "2026-03-24 21:30"
126 ```
127
128 ## 运行时参数
129
130 CLI 将 `debug` 和 `headless` 拆成了两个独立维度:
131
132 ```bash
133 --debug
134 --headless
135 --headed
136 ```
137
138 - `--debug`: 打开调试行为,例如失败时保留更多调试信息
139 - `--headless`: 无头模式运行
140 - `--headed`: 有头模式运行
141
142 如果都不传,CLI 当前默认按 `headless=True` 运行。
143
144 补充:
145
146 - 抖音和快手的 CLI 默认都是无头模式
147 - 如果用户明确要求可见浏览器窗口,或确实需要人工看页面,再显式传 `--headed`
148
149 ## 视频上传参数
150
151 ```bash
152 --file videos/demo.mp4
153 --title "示例标题"
154 --desc "示例简介"
155 --tags 运动,训练
156 --thumbnail videos/demo.png
157 --thumbnail-landscape videos/cover-4x3.png
158 --thumbnail-portrait videos/cover-3x4.png
159 ```
160
161 抖音和视频号支持同时设置两种比例的封面图:
162
163 - `--thumbnail-landscape`: 4:3 横版封面
164 - `--thumbnail-portrait`: 3:4 竖版封面
165 - `--thumbnail`: 兼容旧参数,等同于 3:4 竖版封面
166
167 抖音额外支持:
168
169 ```bash
170 --product-link https://example.com/item
171 --product-title 示例商品
172 ```
173
174 Bilibili 额外要求:
175
176 ```bash
177 --tid 249
178 ```
179
180 - `--tid` 第一版是必填
181 - `--tags` 会映射到 `biliup upload --tag`
182 - `--schedule` 会映射到 Bilibili 所需的时间戳参数
183
184 ## 图文上传参数
185
186 ```bash
187 --images videos/1.png videos/2.png videos/3.png
188 --title "图文标题"
189 --note "图文内容"
190 --tags 图文,测试
191 ```
192
193 图文上传当前限制:
194
195 - 抖音:最多 35 张图片,不支持 GIF
196 - 快手:支持多张图片,建议传真实不同文件,不要把同一路径重复多次
197 - 小红书:支持多张图片,正文 `--note` 可选,但 `--title` 建议始终显式传入
198
199 后续维护 CLI 时,优先看 `sau_cli.py`、`uploader/` 和 `skills/`。
200
200 lines MARKDOWN