ShortVideo.AutoPublisher
repository·main·Indexed 41 days ago
https://github.com/dorisoy/shortvideo.autopublisherA WPF-based automation tool for content creators to manage and publish short videos across platforms like Douyin, Xiaohongshu, Baijiahao, WeChat Channels, and Toutiao. Built with .NET 8.0 and WPF-UI 3.0.4, it utilizes OpenClaw AI agent technology and Microsoft.Playwright (v1.40.0) for browser automation. Features include a queue-based publishing task scheduler, multi-platform account management, a CLI tool (v3.0.1+), and an MCP Server for AI agent integration.
What's inside ShortVideo.AutoPublisher
- ShortVideo.AutoPublisher is a WPF-based desktop application designed for content creators to automate the publishing of short videos across multiple mainstream platforms. It integrates OpenClaw AI agent technology to simulate real user operations via browser automation, providing a unified management system for accounts, video content, and publishing tasks.
Overview of ShortVideo.AutoPublisher Version Evolution
mainShortVideo.AutoPublisher has evolved through three major stages:
- v1.0 (Basic): Manual uploads, single platform (Douyin), and XML configuration.
- v2.0 (Enhanced): Multi-platform support (Xiaohongshu, Baijiahao, Video Accounts, Toutiao), SQLite database storage, batch operations, and WPF-UI 2.x.
- v3.0 AI (Intelligent): The current generation featuring AI automation via OpenClaw, CLI tools, MCP Server support, and Playwright-based browser automation.
Key improvements in the v3.0 series include task scheduling, intelligent retries (Polly), network monitoring, and support for large files (up to 1GB) with breakpoint resumption.
Understand the IAiAgent interface and architecture
mainThe system uses an interface-based architecture to handle different social media platforms. All platform-specific agents implement the
IAiAgentinterface.IAiAgent Interface Methods
LoginAsync(): Performs login verification.UploadVideoAsync(): Handles video file uploading.SetVideoMetadataAsync(): Sets title, description, and tags.SetCoverImageAsync(): Sets the video cover image.PublishAsync(): Finalizes the publishing process.
Architecture Layers
- IAiAgent Interface: Defines the standard contract for all agents.
- AgentBase Class: Provides common functionality including:
- Retry strategies (via Polly)
- Browser control (via Playwright)
- Captcha detection and handling
- Unified status and progress events
- Platform-Specific Implementations: Concrete classes like
DouyinAgent,XiaohongshuAgent,BaijiahaoAgent,WeixinChannelAgent, andToutiaoAgentlocated insrc/ShortVideo.AutoPublisher.Core/OpenClaw/Agents/.
Supported Platforms
- Douyin ✅
- Xiaohongshu ✅
- Baijiahao ✅
- Weixin Channel ✅
- Toutiao ✅
System Architecture and Technology Stack
mainThe project follows a layered architecture built on .NET 8.0 and WPF-UI 3.0.4 using the MVVM pattern.
Architecture Layers:
- Views: WPF-UI 3.0.4 with Fluent Design.
- ViewModels: CommunityToolkit.Mvvm for data binding.
- Services: Core logic including
VideoContentServiceandPublishService. - OpenClaw AI Agent Module: Handles
IAiAgentimplementations, platform agents, task scheduling, and browser management via Microsoft.Playwright. - Infrastructure: Data persistence via SQLite/Dapper, network monitoring, and file downloading.
- Domain: Core entities, enums, and repository interfaces.
Key Dependencies:
- Browser Automation: Microsoft.Playwright (v1.40.0)
- Data Storage: SQLite (v1.0.118) and Dapper (v2.1.35)
- Resilience: Polly (v8.2.0) for transient fault handling
- Image Processing: SixLabors.ImageSharp (v3.1.6) for cover cropping
- Logging: Serilog (v3.1.1)
Understand the OpenClaw AI Agent architecture
mainThe v3.0 AI edition is built on the OpenClaw AI Agent technology and the IAiAgent architecture.
Key architectural components include:
- IAiAgent Interface: A unified agent interface that allows for rapid expansion to new social media platforms.
- Playwright Integration: Uses Playwright for modern, reliable browser automation.
- Task Scheduler: A queue-based management system with concurrency control.
- Resilience: Uses Polly for intelligent retries and includes real-time network monitoring and automatic recovery.
- Large File Handling: Supports videos up to 1GB with breakpoint resumption (断点续传).
- Verification Handling: Intelligent detection of CAPTCHAs with support for manual intervention when necessary.
Project Structure and Component Modules
mainThe repository is organized into several distinct projects:
ShortVideo.AutoPublisher: The main WPF desktop application containing Views, ViewModels, and Services.ShortVideo.AutoPublisher.Core: A shared library containing Domain entities, Infrastructure, OpenClaw AI modules, and Services.ShortVideo.AutoPublisher.Cli: A Command Line Interface tool for managing videos, accounts, publishing, and tasks via commands.ShortVideo.AutoPublisher.Mcp: An MCP (Model Context Protocol) Server that allows AI Agents to integrate with the system using tools likeVideoTools,AccountTools, andPublishTools.
How to obtain platform Cookies
mainTo authenticate, you must provide Cookie data for the target platform.
Method 1: Browser Developer Tools
- Log in to the platform's creator center (e.g.,
https://creator.douyin.com). - Press
F12to open Developer Tools. - Go to the Network tab and refresh the page.
- Select any request and find the
Cookiefield in the Request Headers. Copy the full value.
Method 2: Browser Extensions Use extensions like EditThisCookie or Cookie Editor.
- Log in to the platform.
- Open the extension and select Export (choose JSON format if required, though the app often accepts the raw string).
- Paste the exported data into the application.
Platform Creator Center URLs:
- Douyin:
https://creator.douyin.com - Xiaohongshu:
https://creator.xiaohongshu.com - Baijiahao:
https://baijiahao.baidu.com - Weixin Channel:
https://channels.weixin.qq.com - Toutiao:
https://mp.toutiao.com
- Log in to the platform's creator center (e.g.,
How to obtain platform Cookies for authentication
mainTo use the automated publishing features, you must provide valid Cookies for each platform.
Method 1: Browser Developer Tools
- Open your browser and log in to the target platform's creator center (e.g., Douyin Creator Center).
- Press
F12to open Developer Tools. - Switch to the Network tab.
- Refresh the page and select any request.
- In the Request Headers, find the
Cookiefield and copy the full value.
Method 2: Browser Extensions (Recommended)
Use extensions like EditThisCookie or Cookie Editor (Chrome) or Cookie Quick Manager (Firefox).
- Install the extension and log in to the target platform.
- Click the extension icon.
- Select Export and choose the JSON format.
- Paste the exported data into the application.
Target Creator Center URLs
- Douyin:
https://creator.douyin.com - Xiaohongshu:
https://creator.xiaohongshu.com - Baijiahao:
https://baijiahao.baidu.com - Weixin Channel:
https://channels.weixin.qq.com - Toutiao:
https://mp.toutiao.com
Integrate OpenClaw as an MCP Server for AI Agents
mainYou can expose the AutoPublisher functionality to AI Agents (like Claude Desktop) using the Model Context Protocol (MCP).
1. Configure Claude Desktop
Edit your
claude_desktop_config.jsonfile:- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Add the following configuration (ensure the path to your project is correct):
{ "mcpServers": { "autopublisher": { "command": "dotnet", "args": ["run", "--project", "D:/Git/ShortVideo.AutoPublisher/src/ShortVideo.AutoPublisher.Mcp"] } } }2. Available MCP Tools
Once connected, the AI Agent can call the following tools:
list_videos: Get video library listadd_video: Add video to libraryget_video: Get video detailsdelete_video: Delete videosearch_videos: Search videoslist_accounts: Get platform account listadd_account: Add platform accountdelete_account: Delete accountvalidate_account: Validate account statuspublish_video: Publish video to a specific platformlist_tasks: Get publishing task listget_task_status: Query task statusretry_task: Retry failed taskcancel_task: Cancel taskscheduler_start: Start task schedulerscheduler_stop: Stop task scheduler
- Windows:
Use the CLI for automated video publishing workflows
mainThe v3.0.1 AI edition includes a Command Line Interface (CLI) that allows for scripted operations and integration into automated workflows. The CLI supports the following command categories:
- Video Management: Add, delete, and query videos.
- Account Management: Manage platform accounts.
- Publishing Tasks: Create, query, and manage publishing tasks.
- Scheduler: Start or stop the task scheduler.
This makes the tool suitable for headless or automated environments where manual UI interaction is not desired.
Integrate with AI Agents via MCP Server
mainThe project includes a Model Context Protocol (MCP) server that allows AI agents like Claude Desktop to control the publisher directly.
Setup for Claude Desktop: Add the following to your
claude_desktop_config.json:Windows:
%APPDATA%\Claude\claude_desktop_config.json
macOS:~/Library/Application Support/Claude/claude_desktop_config.json{ "mcpServers": { "autopublisher": { "command": "dotnet", "args": ["run", "--project", "D:/Git/ShortVideo.AutoPublisher/src/ShortVideo.AutoPublisher.Mcp"] } } }Available MCP Tools:
list_videos,add_video,get_video,delete_video,search_videos(Video Library)list_accounts,add_account,delete_account,validate_account,set_default_account(Accounts)publish_video(Publishing)list_tasks,get_task_status,retry_task,cancel_task(Tasks)scheduler_start,scheduler_stop(Scheduler)
Use ShortVideo.AutoPublisher via WPF Desktop Application
mainThe WPF application provides a GUI for managing accounts, videos, and tasks.
- Start the application:
cd src/ShortVideo.AutoPublisher/bin/Debug/net8.0-windows ./ShortVideo.AutoPublisher.exe - Add Accounts: In the Account Management page, select a platform (Douyin, Xiaohongshu, Baijiahao, Weixin Channel, or Toutiao), enter a name, and paste the Cookie data.
- Import Videos: In the Video Library page, click "Add Video", fill in the title, description, and tags, and select the file.
- Create Tasks: Select a video, choose a target platform, and confirm to add the task to the queue.
- Start Scheduler: Click the "Start Scheduler" button to let the AI Agent execute the tasks automatically.
- Start the application: