""" Base Configuration for NCAkit Provides centralized configuration management for all modules. """ import os from pathlib import Path from pydantic_settings import BaseSettings from typing import Optional, Dict, Any class BaseConfig(BaseSettings): """ Base configuration class that all module configs should extend. Provides common settings and utilities. """ # Server Configuration port: int = 8880 log_level: str = "info" debug: bool = False # Environment docker: bool = False dev: bool = False data_dir_path: Optional[str] = None class Config: env_file = ".env" case_sensitive = False extra = "ignore" @property def base_data_dir(self) -> Path: """Get the base data directory path""" if self.data_dir_path: return Path(self.data_dir_path) if self.docker: return Path("/data") # For local development home = Path.home() return home / ".ncakit" def ensure_base_directories(self): """Ensure base directories exist""" self.base_data_dir.mkdir(parents=True, exist_ok=True) class NCAkitConfig(BaseConfig): """ Main NCAkit configuration. Aggregates all module-specific settings. """ # =================== # Video Creator Module Config # =================== pexels_api_key: Optional[str] = None pixabay_api_key: Optional[str] = None # Optional: Pixabay API for additional video source hf_tts: Optional[str] = None whisper_model: str = "tiny.en" whisper_verbose: bool = False concurrency: int = 1 video_cache_size_in_bytes: int = 2684354560 # 2.5GB # =================== # Add new module configs here # Example: # openai_api_key: Optional[str] = None # =================== # =================== # Story Reels Module Config # =================== nvidia_api_key: Optional[str] = None # NVIDIA API key (primary) cf_url: Optional[str] = None # Cloudflare Worker URL (fallback) cf_api: Optional[str] = None # Cloudflare API key (fallback) gemini_api_key: Optional[str] = None # For AI script generation (fallback) groq_api: Optional[str] = None # Groq API key (primary for script generation) # =================== # HF Cloud Storage (Optional) # =================== hf_repo: Optional[str] = None # HF repo for videos (e.g., "username/ncakit-videos") # Note: Uses HF_TOKEN from environment for auth @property def videos_dir_path(self) -> Path: """Directory for storing generated videos""" path = self.base_data_dir / "videos" path.mkdir(parents=True, exist_ok=True) return path @property def temp_dir_path(self) -> Path: """Directory for temporary files""" path = self.base_data_dir / "temp" path.mkdir(parents=True, exist_ok=True) return path @property def whisper_model_dir(self) -> Path: """Directory for Whisper models""" path = self.base_data_dir / "whisper_models" path.mkdir(parents=True, exist_ok=True) return path @property def music_dir_path(self) -> Path: """Directory for music files""" return Path(__file__).parent / "static" / "music" def ensure_directories(self): """Ensure all required directories exist""" self.ensure_base_directories() self.videos_dir_path.mkdir(parents=True, exist_ok=True) self.temp_dir_path.mkdir(parents=True, exist_ok=True) self.whisper_model_dir.mkdir(parents=True, exist_ok=True) # Global config instance config = NCAkitConfig()