Skip to content

Installation & Setup Guide

Prerequisites

  • Python 3.9+
  • Google Chrome (Managed by Playwright)
  • MySQL Database (For task persistence)

Step-by-Step Installation

  1. Navigate to the project directory:

    bash
    cd social-publisher
  2. Create and activate a virtual environment:

    bash
    python3 -m venv venv
    source venv/bin/activate
  3. Install Python dependencies:

    bash
    pip install -r requirements.txt
  4. Install Playwright browsers:

    bash
    playwright install chromium
  5. Configure Environment Variables: Create a .env file in the social-publisher directory with your database credentials:

    env
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_USERNAME=root
    DB_PASSWORD=your_password
    DB_DATABASE=your_database
    DB_PREFIX=sets_
  6. Database Migration: Ensure the database table exists. The system expects a publish_tasks table (prefixed). You can run the migration via the main ThinkPHP project or ensure the table structure matches database.py.

Running the Service

Start the API Server

To start the FastAPI server and the background worker:

bash
./start.sh server

This will launch the server on port 8989.

Run a Single Task via CLI

To publish a video immediately without the server:

bash
./start.sh cli --video "/path/to/video.mp4" --title "My Video" --account_name "default_user"

Docker Deployment (Optional)

If deploying via Docker, ensure the container has:

  • A non-root user (for Chrome security).
  • Necessary system dependencies for Chromium (libnss3, libatk, etc.).
  • HEADLESS=true environment variable set.