auto-douyin
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese抖音视频自动发布技能
Auto-Publishing Skill for Douyin Videos
这个技能用于自动化发布视频到抖音创作者中心。
This skill is used to automate video publishing to the Douyin Creator Center.
使用场景
Usage Scenarios
- 用户需要发布视频到抖音时
- 用户说"发抖音"、"上传抖音"、"发布到抖音"时
- 用户有视频文件需要分发到抖音平台时
- When users need to publish videos to Douyin
- When users say "post to Douyin", "upload to Douyin", "publish to Douyin"
- When users have video files that need to be distributed to the Douyin platform
技术原理
Technical Principles
基于 Playwright 浏览器自动化,模拟真实用户操作抖音创作者中心(https://creator.douyin.com):
- 首次使用需扫码登录,保存 Cookie
- 后续使用 Cookie 自动登录
- 自动化填充标题、话题、封面等信息
- 支持定时发布
Based on Playwright browser automation, simulates real user operations on the Douyin Creator Center (https://creator.douyin.com):
- Scan the QR code to log in for the first use and save cookies
- Auto-login using cookies for subsequent uses
- Automatically fill in information such as title, hashtags, cover, etc.
- Supports scheduled publishing
前置条件
Prerequisites
1. 安装依赖
1. Install Dependencies
bash
pip install playwright
playwright install chromiumbash
pip install playwright
playwright install chromium2. 首次登录获取 Cookie
2. Obtain Cookies via Initial Login
bash
python .opencode/skills/auto-douyin/scripts/get_cookie.py执行后会打开浏览器,使用抖音 APP 扫码登录,登录成功后 Cookie 会自动保存。
bash
python .opencode/skills/auto-douyin/scripts/get_cookie.pyAfter execution, a browser will open. Use the Douyin app to scan the QR code to log in, and cookies will be saved automatically after successful login.
工作流程
Workflow
第一步:确认登录状态
Step 1: Verify Login Status
检查 Cookie 是否存在且有效:
bash
python .opencode/skills/auto-douyin/scripts/check_cookie.py如果 Cookie 失效,需要重新获取:
bash
python .opencode/skills/auto-douyin/scripts/get_cookie.pyCheck if cookies exist and are valid:
bash
python .opencode/skills/auto-douyin/scripts/check_cookie.pyIf cookies are invalid, you need to obtain them again:
bash
python .opencode/skills/auto-douyin/scripts/get_cookie.py第二步:准备视频文件
Step 2: Prepare Video Files
视频文件要求:
- 格式:(推荐)
.mp4 - 分辨率:建议 1080x1920(竖版 9:16)
- 文件大小:建议不超过 4GB
可选:准备同名的封面图片( 或 )
.png.jpgVideo file requirements:
- Format: (recommended)
.mp4 - Resolution: 1080x1920 is recommended (vertical 9:16)
- File size: It is recommended not to exceed 4GB
Optional: Prepare a cover image with the same name ( or )
.png.jpg第三步:发布视频
Step 3: Publish Video
bash
python .opencode/skills/auto-douyin/scripts/publish.py \
--video "视频文件路径" \
--title "视频标题" \
--tags "话题1,话题2,话题3" \
[--cover "封面图片路径"] \
[--schedule "2025-01-31 18:00"]bash
python .opencode/skills/auto-douyin/scripts/publish.py \
--video "path/to/video/file" \
--title "Video Title" \
--tags "hashtag1,hashtag2,hashtag3" \
[--cover "path/to/cover/image"] \
[--schedule "2025-01-31 18:00"]参数说明
Parameter Description
| 参数 | 简写 | 说明 | 必填 |
|---|---|---|---|
| | 视频文件路径 | ✅ |
| | 视频标题(最多30字) | ✅ |
| | 话题标签,逗号分隔 | ❌ |
| | 封面图片路径 | ❌ |
| | 定时发布时间(格式:YYYY-MM-DD HH:MM) | ❌ |
| 无头模式运行(不显示浏览器) | ❌ |
| Parameter | Short Form | Description | Required |
|---|---|---|---|
| | Path to video file | ✅ |
| | Video title (max 30 characters) | ✅ |
| | Hashtags, separated by commas | ❌ |
| | Path to cover image | ❌ |
| | Scheduled publishing time (format: YYYY-MM-DD HH:MM) | ❌ |
| Run in headless mode (browser not displayed) | ❌ |
使用示例
Usage Examples
bash
undefinedbash
undefined立即发布,自动生成封面
Publish immediately, auto-generate cover
python .opencode/skills/auto-douyin/scripts/publish.py
-v ~/Videos/demo.mp4
-t "今天学到一个超实用的技巧"
-g "干货分享,效率提升,学习"
-v ~/Videos/demo.mp4
-t "今天学到一个超实用的技巧"
-g "干货分享,效率提升,学习"
python .opencode/skills/auto-douyin/scripts/publish.py
-v ~/Videos/demo.mp4
-t "I learned a super practical trick today"
-g "dry-goods-sharing, efficiency-improvement, learning"
-v ~/Videos/demo.mp4
-t "I learned a super practical trick today"
-g "dry-goods-sharing, efficiency-improvement, learning"
定时发布,指定封面
Scheduled publishing with specified cover
python .opencode/skills/auto-douyin/scripts/publish.py
-v ~/Videos/demo.mp4
-t "周末vlog|一个人的惬意时光"
-g "vlog,周末日常,生活记录"
-c ~/Videos/demo_cover.png
-s "2025-02-01 18:00"
-v ~/Videos/demo.mp4
-t "周末vlog|一个人的惬意时光"
-g "vlog,周末日常,生活记录"
-c ~/Videos/demo_cover.png
-s "2025-02-01 18:00"
python .opencode/skills/auto-douyin/scripts/publish.py
-v ~/Videos/demo.mp4
-t "Weekend Vlog | A cozy time alone"
-g "vlog, weekend-daily, life-recording"
-c ~/Videos/demo_cover.png
-s "2025-02-01 18:00"
-v ~/Videos/demo.mp4
-t "Weekend Vlog | A cozy time alone"
-g "vlog, weekend-daily, life-recording"
-c ~/Videos/demo_cover.png
-s "2025-02-01 18:00"
无头模式(后台运行)
Headless mode (run in background)
python .opencode/skills/auto-douyin/scripts/publish.py
-v ~/Videos/demo.mp4
-t "测试视频"
--headless
-v ~/Videos/demo.mp4
-t "测试视频"
--headless
undefinedpython .opencode/skills/auto-douyin/scripts/publish.py
-v ~/Videos/demo.mp4
-t "Test Video"
--headless
-v ~/Videos/demo.mp4
-t "Test Video"
--headless
undefined目录结构
Directory Structure
.opencode/skills/auto-douyin/
├── skill.md # 技能说明文档
├── scripts/
│ ├── get_cookie.py # 获取登录 Cookie
│ ├── check_cookie.py # 检查 Cookie 有效性
│ └── publish.py # 发布视频主脚本
└── cookies/
└── douyin.json # Cookie 存储文件(自动生成).opencode/skills/auto-douyin/
├── skill.md # Skill documentation
├── scripts/
│ ├── get_cookie.py # Obtain login cookies
│ ├── check_cookie.py # Check cookie validity
│ └── publish.py # Main video publishing script
└── cookies/
└── douyin.json # Cookie storage file (auto-generated)注意事项
Notes
- Cookie 有效期:Cookie 通常有效期较长,但如果长时间未使用或平台更新,可能需要重新登录
- 发布频率:建议控制发布频率,避免被平台识别为异常行为
- 标题限制:抖音标题最多30字,超出会自动截断
- 话题数量:建议添加3-5个相关话题,提高曝光
- 封面选择:如不指定封面,系统会自动从视频中选取推荐封面
- 定时发布:定时发布时间需在当前时间之后,且在平台允许的时间范围内
- Cookie Validity Period: Cookies usually have a long validity period, but if not used for a long time or the platform is updated, you may need to log in again
- Publishing Frequency: It is recommended to control the publishing frequency to avoid being identified as abnormal behavior by the platform
- Title Limit: Douyin titles are limited to 30 characters; excess will be automatically truncated
- Number of Hashtags: It is recommended to add 3-5 relevant hashtags to increase exposure
- Cover Selection: If no cover is specified, the system will automatically select a recommended cover from the video
- Scheduled Publishing: The scheduled time must be after the current time and within the time range allowed by the platform
常见问题
Frequently Asked Questions
Q: Cookie 失效怎么办?
Q: What to do if cookies expire?
A: 重新运行 扫码登录即可。
get_cookie.pyA: Re-run and log in via QR code again.
get_cookie.pyQ: 上传失败怎么办?
Q: What to do if upload fails?
A: 检查网络连接,确认视频文件格式正确,查看脚本输出的错误信息。
A: Check the network connection, confirm the video file format is correct, and view the error information output by the script.
Q: 如何批量发布?
Q: How to publish in batches?
A: 可以编写循环脚本,依次调用 ,建议每次发布间隔几分钟。
publish.pyA: You can write a loop script to call in sequence, with an interval of a few minutes between each publication recommended.
publish.py参考项目
Reference Project
本技能参考了 social-auto-upload 项目的实现。
This skill refers to the implementation of the social-auto-upload project.