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