Skip to content

Social Publisher Documentation

Social Publisher is an automated tool for publishing videos to social media platforms (currently focusing on Douyin/TikTok China). It leverages Playwright for browser automation to simulate real user behavior, ensuring high success rates and account safety.

Key Features

1. Automated Publishing

  • Smart Publishing: Upload videos, set titles, descriptions, tags, and covers automatically.
  • Robust Interaction: Uses advanced selectors (class*='recommendCover', placeholder) and human-like interactions (scroll, hover, click, type) to handle dynamic UI changes.
  • Error Handling: Comprehensive retry logic for network fluctuations and UI loading delays.
  • Dialog Management: Automatically handles "Confirm" dialogs, "Image Crop" popups, and other interruptions.

2. Account Management

  • Persistent Sessions: Supports multiple accounts with persistent login sessions via cookies.
  • Cookie Validation: Automatic validation of cookie expiration and re-login prompts.
  • Profile Switching: Seamlessly switches between user profiles for batch operations.

3. Stealth Mode & Anti-Detection

  • Stealth Plugin: Integrated playwright-stealth to evade bot detection scripts.
  • Chrome Channel: Uses channel="chrome" to support H.264 video decoding and mimic a real Chrome browser environment.
  • Randomized Delays: Introduces random delays between actions to simulate human behavior.

4. Cover Management

  • AI Cover Integration: Supports selecting AI-generated covers during the publishing flow (Optimization in progress).
  • Fallback Logic: If AI cover selection fails, automatically falls back to default video frames or local uploads.
  • Independent Generation: Decoupled cover generation from video publishing, allowing covers to be regenerated and managed separately via the MidjourneyTool.

5. Architecture

  • API Service: FastAPI-based RESTful API for integration with other systems (app.py).
  • Asynchronous Workers: Background task workers (worker.py) for handling long-running upload jobs, powered by SQLite queue.

Directory Structure

social-publisher/
├── core/               # Core logic (Browser, Account management)
├── platforms/          # Platform-specific implementations (Douyin)
├── service/            # Service layer (Business logic)
├── utils/              # Utilities (Logger, Helpers)
├── app.py              # API Entry point (FastAPI)
├── worker.py           # Background task worker
├── database.py         # Database models and connection
├── start.sh            # Main entry script
└── requirements.txt    # Python dependencies

Recent Updates

  • Fix Title/Description Missing: Resolved issues where title and description were not being filled by switching to click() + type() interaction pattern and ensuring elements are scrolled into view.
  • Enhanced Selectors: Updated CSS selectors to handle dynamic class names (e.g., recommendCover-vWWsHB) and multiple DOM structures.
  • Browser Recording: Added record.sh tool for manual recording of browser sessions to capture updated selectors and debug interaction flows.

Next Steps