How to Add New Social Media Platform Integrations to MoneyPrinterV2

To add a new social media platform to MoneyPrinterV2, you must create a provider class in src/classes/, extend the cache utilities in src/cache.py, add configuration getters in src/config.py, define UI constants in src/constants.py, and register the new provider in the CLI driver at src/main.py.

MoneyPrinterV2 is built around a modular, plug-in style architecture that separates platform-specific automation logic from core utilities. By following the established patterns used by YouTube and Twitter, you can extend the system to support additional social media platforms while leveraging existing infrastructure for caching, LLM content generation, and browser automation.

Understanding the Provider Architecture

The codebase implements a layered provider pattern where each social media platform is encapsulated in a standalone class. These provider classes handle browser automation, content generation, caching, and uploading independently.

Key architectural components to understand before adding a new integration:

  • Provider classes – Located in src/classes/, these contain platform-specific Selenium automation (e.g., YouTube.py, Twitter.py)
  • Cache utilitiessrc/cache.py provides JSON-based caching functions like get_youtube_cache_path() and the generic get_provider_cache_path()
  • Configuration layersrc/config.py reads config.json and exposes typed getters like get_headless()
  • Constantssrc/constants.py stores menu strings and Selenium selectors in lists like OPTIONS
  • CLI driversrc/main.py builds the interactive menu, instantiates provider classes, and drives the sub-menu loops

Step 1: Create the Provider Class

Create a new file in src/classes/YourPlatform.py. The class must initialize with four required parameters: account_uuid, account_nickname, fp_profile_path, and topic.

Constructor and WebDriver Setup

The constructor should configure Firefox options, validate the profile path, and initialize the Selenium WebDriver using the pattern established in existing providers:

import os
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
from webdriver_manager.firefox import GeckoDriverManager
from config import get_headless
from status import info, success, error

class YourPlatform:
    def __init__(self, account_uuid: str, account_nickname: str,
                 fp_profile_path: str, topic: str) -> None:
        self.account_uuid = account_uuid
        self.account_nickname = account_nickname
        self.fp_profile_path = fp_profile_path
        self.topic = topic

        # Configure Firefox profile

        self.options = Options()
        if get_headless():
            self.options.add_argument("--headless")
        if not os.path.isdir(fp_profile_path):
            raise ValueError(f"Firefox profile path does not exist: {fp_profile_path}")
        self.options.add_argument("-profile")
        self.options.add_argument(fp_profile_path)

        # Initialize WebDriver

        self.service = Service(GeckoDriverManager().install())
        self.browser = webdriver.Firefox(
            service=self.service, options=self.options
        )

Implement Platform Actions

Add methods for content generation and posting. Use the centralized LLM provider for generating captions, following the pattern in src/classes/Twitter.py:

from llm_provider import generate_text
from utils import question

def generate_caption(self) -> str:
    """Generate platform-specific caption using LLM."""
    return generate_text(
        f"Write a caption for {self.topic} suitable for this platform."
    )

def post(self) -> None:
    """Execute the post automation workflow."""
    caption = self.generate_caption()
    self.browser.get("https://your-platform.com")
    # Add Selenium automation steps here

    success("Posted successfully!")

Step 2: Extend Cache and Configuration

If your platform requires persistent storage for metadata or credentials, extend the caching layer in src/cache.py:

def get_yourplatform_cache_path() -> str:
    return os.path.join(get_cache_path(), 'yourplatform.json')

Update the get_provider_cache_path function to recognize the new provider:

if provider == "yourplatform":
    return get_yourplatform_cache_path()

For platform-specific configuration values such as API keys or rate limits, add typed getters in src/config.py:

def get_yourplatform_api_key() -> str:
    with open(os.path.join(ROOT_DIR, "config.json"), "r") as file:
        return json.load(file).get("yourplatform_api_key", "")

Step 3: Update Constants and UI

Define menu strings and UI constants in src/constants.py:

YOURPLATFORM_OPTIONS = [
    "Post something",
    "Show all Posts",
    "Setup CRON Job",
    "Quit"
]

Append the new platform to the main menu by adding to the OPTIONS list:

OPTIONS.append("YourPlatform Automation")

Step 4: Wire the CLI Driver

Integrate the new provider into the menu system in src/main.py. Add a new elif block following the pattern established for YouTube (lines 41-84) and Twitter (lines 166-227):

elif user_input == N:  # Replace N with the appropriate index

    info("Starting YourPlatform Bot...")
    cached_accounts = get_accounts("yourplatform")
    
    # Account selection/create flow (mirror YouTube/Twitter pattern)

    if not cached_accounts:
        # Create new account logic

        pass
    else:
        # Select from existing accounts

        pass
    
    # Instantiate provider

    yourplatform = YourPlatform(
        selected_account["id"],
        selected_account["nickname"],
        selected_account["firefox_profile"],
        selected_account["topic"]
    )
    
    # Sub-menu loop

    while True:
        info("\n============ OPTIONS ============", False)
        for idx, opt in enumerate(YOURPLATFORM_OPTIONS):
            print(colored(f" {idx + 1}. {opt}", "cyan"))
        info("=================================\n", False)
        
        sub_choice = int(question("Select an option: "))
        # Dispatch to yourplatform.post(), etc.

Step 5: Add Preflight Checks (Optional)

If your platform requires specific external binaries or drivers, add validation to scripts/preflight_local.py to warn users during initial setup.

Summary

  • Create a provider class in src/classes/YourPlatform.py that initializes with account_uuid, account_nickname, fp_profile_path, and topic, then implements platform-specific Selenium automation.
  • Extend caching by adding get_yourplatform_cache_path() to src/cache.py and updating get_provider_cache_path() to recognize the new provider.
  • Add configuration getters in src/config.py for any platform-specific settings like API keys.
  • Define UI constants in src/constants.py including YOURPLATFORM_OPTIONS and append the platform name to the main OPTIONS list.
  • Wire the CLI in src/main.py by adding an elif block that instantiates your provider class and implements the account selection and sub-menu loop following the YouTube/Twitter pattern.

Frequently Asked Questions

Where should I place the new provider class?

Place the new provider class in src/classes/YourPlatform.py, following the naming convention used by existing implementations like src/classes/YouTube.py and src/classes/Twitter.py. The class must expose the same initialization signature requiring account_uuid, account_nickname, fp_profile_path, and topic parameters.

Do I need to modify the caching system for every new platform?

You only need to extend the caching system if your platform requires persistent storage for metadata, upload history, or credentials. If needed, add a specific path function like get_yourplatform_cache_path() to src/cache.py and update the get_provider_cache_path() dispatcher to recognize your provider string.

How does the LLM integration work for content generation?

MoneyPrinterV2 uses a centralized llm_provider module for content generation. In your provider class, import generate_text from llm_provider and call it with a prompt string to generate captions, descriptions, or comments specific to your platform's content style, following the implementation pattern established in src/classes/Twitter.py.

Can I use a different browser instead of Firefox?

The existing architecture initializes Firefox via webdriver.Firefox with GeckoDriverManager. While the provided code assumes Firefox profiles for session persistence, you could adapt the __init__ method to use Chrome or another browser by importing the appropriate Selenium WebDriver and updating the options configuration, though this would deviate from the established pattern in src/classes/YouTube.py.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →