Initial commit - Video Service for Coolify

This commit is contained in:
2025-12-17 10:07:44 +01:00
commit baa1675738
46 changed files with 2386 additions and 0 deletions

86
app/config.py Executable file
View File

@@ -0,0 +1,86 @@
"""
Video-Service Configuration
Using pydantic-settings for type-safe environment configuration
"""
from functools import lru_cache
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
"""Application settings loaded from environment variables."""
# Environment
environment: str = "development"
debug: bool = False
# API Security
api_key: str = "change-me-in-production"
jwt_secret: str = "change-me-in-production"
jwt_algorithm: str = "HS256"
jwt_expiry_hours: int = 1
# Redis
redis_url: str = "redis://localhost:6379/0"
# Storage
storage_path: str = "/app/storage"
# WordPress Integration
wordpress_webhook_url: str = ""
wordpress_api_key: str = ""
# CORS
allowed_origins: str = "http://localhost:8300"
# Upload Limits
max_upload_size_mb: int = 2048 # 2GB default
# FFmpeg Settings
ffmpeg_threads: int = 2
hls_segment_duration: int = 6
video_qualities: str = "360p,720p,1080p"
# Production Domain
video_domain: str = "videos.islandpferde-melanieworbs.de"
# Public URL for development (external access from browser)
# In production, https://{video_domain} is used instead
video_public_url: str = ""
@property
def base_url(self) -> str:
"""Get the base URL for video streaming (accessible from browser)."""
if self.environment == "production":
return f"https://{self.video_domain}"
elif self.video_public_url:
return self.video_public_url.rstrip("/")
else:
return "http://localhost:8500"
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
case_sensitive = False
@property
def allowed_origins_list(self) -> list[str]:
"""Parse comma-separated origins into list."""
return [origin.strip() for origin in self.allowed_origins.split(",")]
@property
def video_qualities_list(self) -> list[str]:
"""Parse comma-separated qualities into list."""
return [q.strip() for q in self.video_qualities.split(",")]
@property
def max_upload_size_bytes(self) -> int:
"""Convert MB to bytes."""
return self.max_upload_size_mb * 1024 * 1024
@lru_cache
def get_settings() -> Settings:
"""Cached settings instance."""
return Settings()