SPB Git forge

spb/crea-ka

Public

Créa·Ka — annuaire public cross-plateforme des créateurs de contenu québécois (crea-ka.com)

52commits 1branches 0releases
11.3 MBsize
maindefault branch
19 days agolast push
Python 73.6% HTML 13.2% TypeScript 6% JavaScript 4.5% CSS 1.7% Dockerfile 0.6%
2.3 KB · 63 lines python
Raw Blame History
1#!/usr/bin/env python32# ==============================================================================3# Author: Simon-Pierre Boucher <contact@spboucher.ai>4# File:   run.py5# Desc:   Point d'entrée Créa-Ka — `sync`, `watch`, `serve` (calqué sur Lou-Ka)6# ==============================================================================7"""Utilisation :8    python run.py sync [source ...]     # synchronise (découverte + enrichissement)9    python run.py watch [heures]        # synchronise en boucle (défaut 24 h)10    python run.py serve [port]          # démarre l'API + le frontend (défaut 8160)11    python run.py optout <nom|plateforme:handle>   # retrait manuel immédiat12"""13from __future__ import annotations1415import os16import sys17from pathlib import Path1819# Charger .env (SCRAPFLY_KEY, FIRECRAWL_API_KEY, YOUTUBE_API_KEY…) sans dépendance20_env = Path(__file__).parent / ".env"21if _env.exists():22    for line in _env.read_text().splitlines():23        line = line.strip()24        if line and not line.startswith("#") and "=" in line:25            k, _, v = line.partition("=")26            os.environ.setdefault(k.strip(), v.strip())272829def main() -> None:30    cmd = sys.argv[1] if len(sys.argv) > 1 else "serve"31    if cmd == "sync":32        from creaka import ingest33        ingest.run(sys.argv[2:] or None)34    elif cmd == "watch":35        from creaka import ingest36        hours = float(sys.argv[2]) if len(sys.argv) > 2 else 24.037        ingest.watch(int(hours * 3600))38    elif cmd == "optout":39        if len(sys.argv) < 3:40            print(__doc__)41            sys.exit(1)42        from creaka import db, ethics43        target = sys.argv[2]44        is_account = ":" in target45        ethics.add_optout(name=None if is_account else target,46                          account=target if is_account else None,47                          reason="retrait manuel (CLI)")48        n = db.apply_optout(db.connect(),49                            name=None if is_account else target,50                            account=target if is_account else None)51        print(f"[crea-ka] opt-out enregistré, {n} fiche(s) masquée(s)")52    elif cmd == "serve":53        import uvicorn54        port = int(sys.argv[2]) if len(sys.argv) > 2 else 816055        uvicorn.run("creaka.web:app", host="0.0.0.0", port=port)56    else:57        print(__doc__)58        sys.exit(1)596061if __name__ == "__main__":62    main()63