This repository has been archived on 2026-05-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
GallerySubscriber/backend/app/config.py
T
2026-01-24 23:50:09 -05:00

50 lines
1.3 KiB
Python

"""Application configuration using pydantic-settings."""
from functools import lru_cache
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
"""Application settings loaded from environment variables."""
# Database
database_url: str = "postgresql://gdl:password@localhost:5432/gallery_subscriber"
# Redis
redis_url: str = "redis://localhost:6379/0"
# Security
secret_key: str = "change-me-in-production"
# Note: extension_api_key is now stored in database and auto-generated
# Paths
download_path: str = "/data/downloads"
config_path: str = "/data/config"
cookies_path: str = "/data/cookies"
# Download settings
download_parallel_limit: int = 3
download_rate_limit: float = 3.0
# Note: check_interval is now per-source and stored in database
# Server
host: str = "0.0.0.0"
port: int = 8080
debug: bool = False
log_level: str = "INFO"
@property
def async_database_url(self) -> str:
"""Convert database URL to async version for asyncpg."""
return self.database_url.replace("postgresql://", "postgresql+asyncpg://")
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
@lru_cache
def get_settings() -> Settings:
"""Get cached settings instance."""
return Settings()