ShortVideo.AutoPublisher

repository·main·Indexed 41 days ago

https://github.com/dorisoy/shortvideo.autopublisher

A 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.

Tokens
10.4K
Snippets
32
Records
48
Agent score
48%

What's inside ShortVideo.AutoPublisher

  1. Overview of ShortVideo.AutoPublisher

    main
    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.
  2. Overview of ShortVideo.AutoPublisher Version Evolution

    main

    ShortVideo.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.

  3. Understand the IAiAgent interface and architecture

    main

    The system uses an interface-based architecture to handle different social media platforms. All platform-specific agents implement the IAiAgent interface.

    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

    1. IAiAgent Interface: Defines the standard contract for all agents.
    2. AgentBase Class: Provides common functionality including:
      • Retry strategies (via Polly)
      • Browser control (via Playwright)
      • Captcha detection and handling
      • Unified status and progress events
    3. Platform-Specific Implementations: Concrete classes like DouyinAgent, XiaohongshuAgent, BaijiahaoAgent, WeixinChannelAgent, and ToutiaoAgent located in src/ShortVideo.AutoPublisher.Core/OpenClaw/Agents/.

    Supported Platforms

    • Douyin ✅
    • Xiaohongshu ✅
    • Baijiahao ✅
    • Weixin Channel ✅
    • Toutiao ✅
  4. System Architecture and Technology Stack

    main

    The 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 VideoContentService and PublishService.
    • OpenClaw AI Agent Module: Handles IAiAgent implementations, 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)
  5. Understand the OpenClaw AI Agent architecture

    main

    The 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.
  6. Project Structure and Component Modules

    main

    The 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 like VideoTools, AccountTools, and PublishTools.
  7. How to obtain platform Cookies

    main

    To authenticate, you must provide Cookie data for the target platform.

    Method 1: Browser Developer Tools

    1. Log in to the platform's creator center (e.g., https://creator.douyin.com).
    2. Press F12 to open Developer Tools.
    3. Go to the Network tab and refresh the page.
    4. Select any request and find the Cookie field in the Request Headers. Copy the full value.

    Method 2: Browser Extensions Use extensions like EditThisCookie or Cookie Editor.

    1. Log in to the platform.
    2. Open the extension and select Export (choose JSON format if required, though the app often accepts the raw string).
    3. 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
  8. How to obtain platform Cookies for authentication

    main

    To use the automated publishing features, you must provide valid Cookies for each platform.

    Method 1: Browser Developer Tools

    1. Open your browser and log in to the target platform's creator center (e.g., Douyin Creator Center).
    2. Press F12 to open Developer Tools.
    3. Switch to the Network tab.
    4. Refresh the page and select any request.
    5. In the Request Headers, find the Cookie field and copy the full value.

    Use extensions like EditThisCookie or Cookie Editor (Chrome) or Cookie Quick Manager (Firefox).

    1. Install the extension and log in to the target platform.
    2. Click the extension icon.
    3. Select Export and choose the JSON format.
    4. 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
  9. Integrate OpenClaw as an MCP Server for AI Agents

    main

    You 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.json file:

    • 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 list
    • add_video: Add video to library
    • get_video: Get video details
    • delete_video: Delete video
    • search_videos: Search videos
    • list_accounts: Get platform account list
    • add_account: Add platform account
    • delete_account: Delete account
    • validate_account: Validate account status
    • publish_video: Publish video to a specific platform
    • list_tasks: Get publishing task list
    • get_task_status: Query task status
    • retry_task: Retry failed task
    • cancel_task: Cancel task
    • scheduler_start: Start task scheduler
    • scheduler_stop: Stop task scheduler
  10. Use the CLI for automated video publishing workflows

    main

    The 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.

  11. Integrate with AI Agents via MCP Server

    main

    The 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)
  12. Use ShortVideo.AutoPublisher via WPF Desktop Application

    main

    The WPF application provides a GUI for managing accounts, videos, and tasks.

    1. Start the application:
      cd src/ShortVideo.AutoPublisher/bin/Debug/net8.0-windows
      ./ShortVideo.AutoPublisher.exe
    2. 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.
    3. Import Videos: In the Video Library page, click "Add Video", fill in the title, description, and tags, and select the file.
    4. Create Tasks: Select a video, choose a target platform, and confirm to add the task to the queue.
    5. Start Scheduler: Click the "Start Scheduler" button to let the AI Agent execute the tasks automatically.