""" Text Story Module for NCAkit Generates fake iMessage-style text conversation videos. """ from fastapi import FastAPI import logging # Module Metadata MODULE_NAME = "text_story" MODULE_PREFIX = "/api/text-story" MODULE_DESCRIPTION = "Generate fake iMessage-style text story videos with TTS" logger = logging.getLogger(__name__) def register(app: FastAPI, config): """ Register the text story module with FastAPI. Initializes services and adds routes. """ from .router import router logger.info("Registering text_story module...") # Validate TTS config if not config.hf_tts: logger.warning("HF_TTS not configured! TTS generation will fail.") # Create required directories import os os.makedirs("videos/text_story", exist_ok=True) # Create gameplay backgrounds folder in persistent storage if os.path.exists("/data"): os.makedirs("/data/gameplay_backgrounds", exist_ok=True) logger.info("Created /data/gameplay_backgrounds folder for gameplay videos") # Check gameplay backgrounds backgrounds_paths = [ "/data/gameplay_backgrounds", "assets/gameplay_backgrounds" ] bg_found = False for path in backgrounds_paths: if os.path.exists(path): count = len([f for f in os.listdir(path) if f.endswith('.mp4')]) if count > 0: logger.info(f"Found {count} gameplay backgrounds in {path}") bg_found = True break if not bg_found: logger.warning("No gameplay backgrounds found! Will use solid color background.") logger.info("Add .mp4 files to /data/gameplay_backgrounds for video backgrounds") # Register router app.include_router(router) logger.info("text_story module registered successfully") # Export router for direct import from .router import router __all__ = ["router", "register", "MODULE_NAME", "MODULE_PREFIX", "MODULE_DESCRIPTION"]