auto-weixin-video

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

微信视频号自动发布技能

WeChat Channels Auto-Publishing Skill

这个技能用于自动化发布视频到微信视频号创作者中心。
This skill is used to automate video publishing to the WeChat Channels Creator Center.

使用场景

Usage Scenarios

  • 用户需要发布视频到视频号时
  • 用户说"发视频号"、"上传视频号"、"发布到微信视频号"时
  • 用户有视频文件需要分发到视频号平台时
  • When users need to publish videos to WeChat Channels
  • When users say "publish to Channels", "upload to Channels", "publish to WeChat Channels"
  • When users have video files that need to be distributed to the WeChat Channels platform

技术原理

Technical Principle

基于 Playwright 浏览器自动化,模拟真实用户操作微信视频号创作者中心(https://channels.weixin.qq.com):
  1. 首次使用需微信扫码登录,保存 Cookie
  2. 后续使用 Cookie 自动登录
  3. 自动化填充标题、话题、短标题等信息
  4. 支持定时发布、原创声明、添加到合集
Based on Playwright browser automation, simulates real user operations on the WeChat Channels Creator Center (https://channels.weixin.qq.com):
  1. WeChat QR code login is required for first-time use, and cookies will be saved
  2. Automatic login using saved cookies for subsequent uses
  3. Automatically fills in information such as title, topics, short title, etc.
  4. Supports scheduled publishing, original content declaration, and adding to collections

前置条件

Prerequisites

1. 安装依赖

1. Install Dependencies

bash
pip install playwright
playwright install chromium
bash
pip install playwright
playwright install chromium

2. 首次登录获取 Cookie

2. Obtain Login Cookie for First-Time Use

bash
python .opencode/skills/auto-weixin-video/scripts/get_cookie.py
执行后会打开浏览器,使用微信扫码登录,登录成功后 Cookie 会自动保存。
bash
python .opencode/skills/auto-weixin-video/scripts/get_cookie.py
After execution, a browser will open. Log in via WeChat QR code, and the cookie will be automatically saved after successful login.

工作流程

Workflow

第一步:确认登录状态

Step 1: Verify Login Status

检查 Cookie 是否存在且有效:
bash
python .opencode/skills/auto-weixin-video/scripts/check_cookie.py
如果 Cookie 失效,需要重新获取:
bash
python .opencode/skills/auto-weixin-video/scripts/get_cookie.py
Check if the cookie exists and is valid:
bash
python .opencode/skills/auto-weixin-video/scripts/check_cookie.py
If the cookie is invalid, re-obtain it:
bash
python .opencode/skills/auto-weixin-video/scripts/get_cookie.py

第二步:准备视频文件

Step 2: Prepare Video Files

视频文件要求:
  • 格式:
    .mp4
    (推荐)
  • 分辨率:建议 1080x1920(竖版 9:16)或 1920x1080(横版 16:9)
  • 时长:建议 1 分钟以内效果最佳
Video file requirements:
  • Format:
    .mp4
    (recommended)
  • Resolution: Recommended 1080x1920 (vertical 9:16) or 1920x1080 (horizontal 16:9)
  • Duration: Best within 1 minute

第三步:发布视频

Step 3: Publish Video

bash
python .opencode/skills/auto-weixin-video/scripts/publish.py \
    --video "视频文件路径" \
    --title "视频标题" \
    --tags "话题1,话题2,话题3" \
    [--original] \
    [--schedule "2025-01-31 18:00"]
bash
python .opencode/skills/auto-weixin-video/scripts/publish.py \
    --video "video file path" \
    --title "video title" \
    --tags "topic1,topic2,topic3" \
    [--original] \
    [--schedule "2025-01-31 18:00"]

参数说明

Parameter Description

参数简写说明必填
--video
-v
视频文件路径
--title
-t
视频标题
--tags
-g
话题标签,逗号分隔
--original
-o
声明原创
--category
-c
原创类型(如:生活、科技)
--schedule
-s
定时发布时间(格式:YYYY-MM-DD HH:MM)
--draft
保存为草稿而不发布
--headless
无头模式运行(不显示浏览器)
ParameterShort FormDescriptionRequired
--video
-v
Video file path
--title
-t
Video title
--tags
-g
Topic tags, separated by commas
--original
-o
Declare as original content
--category
-c
Original content type (e.g., Life, Technology)
--schedule
-s
Scheduled publishing time (format: YYYY-MM-DD HH:MM)
--draft
Save as draft instead of publishing
--headless
Run in headless mode (browser not displayed)

使用示例

Usage Examples

bash
undefined
bash
undefined

立即发布

Publish immediately

python .opencode/skills/auto-weixin-video/scripts/publish.py
-v ~/Videos/demo.mp4
-t "今天学到一个超实用的技巧"
-g "干货分享,效率提升,学习"
python .opencode/skills/auto-weixin-video/scripts/publish.py
-v ~/Videos/demo.mp4
-t "I learned a super practical trick today"
-g "dry goods sharing, efficiency improvement, learning"

声明原创 + 定时发布

Declare original + scheduled publishing

python .opencode/skills/auto-weixin-video/scripts/publish.py
-v ~/Videos/demo.mp4
-t "周末vlog|一个人的惬意时光"
-g "vlog,周末日常,生活记录"
--original
-s "2025-02-01 18:00"
python .opencode/skills/auto-weixin-video/scripts/publish.py
-v ~/Videos/demo.mp4
-t "Weekend Vlog | A cozy time alone"
-g "vlog, weekend daily, life record"
--original
-s "2025-02-01 18:00"

保存为草稿

Save as draft

python .opencode/skills/auto-weixin-video/scripts/publish.py
-v ~/Videos/demo.mp4
-t "测试视频"
--draft
undefined
python .opencode/skills/auto-weixin-video/scripts/publish.py
-v ~/Videos/demo.mp4
-t "Test Video"
--draft
undefined

目录结构

Directory Structure

.opencode/skills/auto-weixin-video/
├── skill.md              # 技能说明文档
├── scripts/
│   ├── get_cookie.py     # 获取登录 Cookie
│   ├── check_cookie.py   # 检查 Cookie 有效性
│   └── publish.py        # 发布视频主脚本
└── cookies/
    └── weixin_video.json # Cookie 存储文件(自动生成)
.opencode/skills/auto-weixin-video/
├── skill.md              # Skill documentation
├── scripts/
│   ├── get_cookie.py     # Obtain login cookie
│   ├── check_cookie.py   # Check cookie validity
│   └── publish.py        # Main video publishing script
└── cookies/
    └── weixin_video.json # Cookie storage file (automatically generated)

注意事项

Notes

  1. Cookie 有效期:微信 Cookie 有效期相对较短,建议每次使用前检查
  2. 发布频率:建议控制发布频率,避免被平台识别为异常行为
  3. 短标题:系统会自动从标题生成 6-16 字的短标题
  4. 话题数量:建议添加 3-5 个相关话题
  5. 原创声明:勾选原创需要符合平台原创规范,否则可能被处罚
  6. 合集:如果账号有合集,视频会自动添加到第一个合集
  1. Cookie Validity Period: WeChat cookies have a relatively short validity period, so it is recommended to check before each use
  2. Publishing Frequency: It is recommended to control the publishing frequency to avoid being identified as abnormal behavior by the platform
  3. Short Title: The system will automatically generate a short title of 6-16 characters from the main title
  4. Number of Topics: It is recommended to add 3-5 relevant topics
  5. Original Content Declaration: Checking the original content option must comply with the platform's original content specifications, otherwise penalties may be imposed
  6. Collections: If the account has collections, the video will be automatically added to the first collection

常见问题

Frequently Asked Questions

Q: Cookie 失效怎么办?

Q: What to do if the cookie becomes invalid?

A: 重新运行
get_cookie.py
扫码登录即可。
A: Re-run
get_cookie.py
and log in via QR code.

Q: 上传失败怎么办?

Q: What to do if upload fails?

A: 检查网络连接,确认视频文件格式正确。视频号对 H264 编码支持最好。
A: Check the network connection and confirm the video file format is correct. WeChat Channels supports H264 encoding best.

Q: 如何批量发布?

Q: How to publish in batches?

A: 可以编写循环脚本,依次调用
publish.py
,建议每次发布间隔几分钟。
A: You can write a loop script to call
publish.py
in sequence, with an interval of a few minutes between each publication recommended.

参考项目

Reference Project

本技能参考了 social-auto-upload 项目的实现。
This skill refers to the implementation of the social-auto-upload project.