Nouvelle version réécrite de zéro : recherche multi-sources (Vostfree, French-Manga), extraction 2 niveaux, proxy vidéo intégré, streaming/téléchargement HLS, métadonnées Kitsu, bibliothèque locale, comptes JWT + administration, découverte fusionnée, indexeur Torznab (Sonarr/Prowlarr).
32 lines
973 B
Python
32 lines
973 B
Python
"""Chargement des configurations de scraping externalisées (sélecteurs YAML).
|
|
|
|
Permet de réparer un site cassé en modifiant un fichier de config sans toucher
|
|
au code. Chaque source peut avoir un fichier `configs/<nom_source>.yaml`.
|
|
"""
|
|
|
|
import logging
|
|
from functools import lru_cache
|
|
from typing import Any
|
|
|
|
import yaml
|
|
|
|
from app.config import get_settings
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@lru_cache
|
|
def load_scraper_config(source_name: str) -> dict[str, Any]:
|
|
path = get_settings().scrapers_config_dir / f"{source_name}.yaml"
|
|
if not path.exists():
|
|
logger.debug("Pas de config externe pour %s (%s)", source_name, path)
|
|
return {}
|
|
try:
|
|
with path.open(encoding="utf-8") as fh:
|
|
config = yaml.safe_load(fh) or {}
|
|
logger.info("Config de scraping chargée pour %s", source_name)
|
|
return config
|
|
except yaml.YAMLError as exc:
|
|
logger.error("Config %s invalide : %s", path, exc)
|
|
return {}
|