42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
from __future__ import annotations
|
|
|
|
from functools import lru_cache
|
|
from pydantic import Field
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
|
|
|
app_env: str = "dev"
|
|
app_base_url: str = "http://localhost:8000"
|
|
app_timezone: str = "UTC"
|
|
app_internal_url: str = "http://app:8000"
|
|
app_port: int = 8000
|
|
|
|
telegram_bot_token: str
|
|
|
|
spotify_client_id: str
|
|
spotify_client_secret: str
|
|
spotify_redirect_uri: str
|
|
spotify_default_market: str = "US"
|
|
|
|
lastfm_api_key: str | None = None
|
|
|
|
internal_job_token: str
|
|
db_path: str = "/data/app.db"
|
|
|
|
default_playlist_size: int = 30
|
|
min_new_ratio: float = Field(default=0.8, ge=0.0, le=1.0)
|
|
recent_days_window: int = 5
|
|
playlist_visibility: str = "private"
|
|
|
|
@property
|
|
def database_url(self) -> str:
|
|
return f"sqlite+aiosqlite:///{self.db_path}"
|
|
|
|
|
|
@lru_cache
|
|
def get_settings() -> Settings:
|
|
return Settings()
|