54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
from functools import lru_cache
|
|
from pathlib import Path
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(env_prefix="OHM_", env_file=".env", extra="ignore")
|
|
|
|
app_name: str = "Ohm Stream Downloader"
|
|
debug: bool = False
|
|
|
|
# Données
|
|
data_dir: Path = BASE_DIR / "data"
|
|
download_dir: Path = BASE_DIR / "downloads"
|
|
database_path: Path = BASE_DIR / "data" / "ohm.db"
|
|
|
|
# Sécurité — à surcharger via OHM_SECRET_KEY en production
|
|
secret_key: str = "change-me-in-production"
|
|
access_token_ttl_minutes: int = 15
|
|
refresh_token_ttl_days: int = 30
|
|
|
|
# Scraping
|
|
http_timeout: float = 20.0
|
|
user_agent: str = "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
|
|
scrapers_config_dir: Path = BASE_DIR / "app" / "scrapers" / "configs"
|
|
|
|
# Téléchargements
|
|
max_parallel_downloads: int = 3
|
|
|
|
# Kitsu
|
|
kitsu_base_url: str = "https://kitsu.io/api/edge"
|
|
metadata_cache_ttl_hours: int = 72
|
|
|
|
# Mise à jour (dépôt public — lecture anonyme de l'API Gitea)
|
|
gitea_url: str = "https://git.lanro.eu"
|
|
gitea_repo: str = "Roman/ohm_streaming"
|
|
# Déploiement Docker — Watchtower compagnon
|
|
watchtower_url: str = ""
|
|
watchtower_token: str = ""
|
|
|
|
def ensure_dirs(self) -> None:
|
|
self.data_dir.mkdir(parents=True, exist_ok=True)
|
|
self.download_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
@lru_cache
|
|
def get_settings() -> Settings:
|
|
settings = Settings()
|
|
settings.ensure_dirs()
|
|
return settings
|