✨ Suppression de la partie légal

This commit is contained in:
Orionis committed 2026-11-16 21:42:28 +01:00
1 parent 0c5189d9ca
commit d0a95adeb9
36 files changed
+73 -572

No files matched your search

+5 -28
View File
@@ -2,22 +2,16 @@
Endpoints :
- GET /healthz
- GET /check-source?source=<url|domaine>
- POST /run {"source","series","lang","group"?,"max_chapters"?,"mock_llm"?,"with_ocr"?,"out"?}
Toutes les requêtes passent par legal-source-check : une source bloquée
(mangas-origines, keiyoushi.github.io, domaine non déclaré) n'est jamais traitée.
"""
from __future__ import annotations
import json
import os
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
from urllib.parse import parse_qs, urlparse
from urllib.parse import urlparse
from . import legal, pipeline
from . import pipeline
INDEX_HTML = """<!doctype html>
<html lang="fr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
@@ -25,12 +19,8 @@ INDEX_HTML = """<!doctype html>
<style>body{font-family:system-ui,sans-serif;max-width:46rem;margin:2rem auto;padding:0 1rem;color:#222}input,button{padding:.45rem;margin:.2rem}input{width:100%;box-sizing:border-box}fieldset{border:1px solid #ccc;border-radius:8px;margin-bottom:1rem}legend{font-weight:600}button{cursor:pointer;background:#222;color:#fff;border:0;border-radius:6px}pre{background:#f4f4f4;padding:1rem;border-radius:8px;overflow:auto;white-space:pre-wrap}.warn{color:#a00;font-size:.85rem}</style>
</head><body>
<h1>Scalper</h1>
<p>Pipeline légal de scraping + traduction de chapitres. <span class="warn">Sources non déclarées ou bloquées (mangas-origines, keiyoushi.github.io) refusées.</span></p>
<fieldset><legend>1. Vérifier une source</legend>
<input id="cs-source" placeholder="https://... ou demo ou mangadex"><br>
<button onclick="checkSource()">check-source</button>
</fieldset>
<fieldset><legend>2. Lancer un pipeline (check → scrape → clean → translate → QA → export)</legend>
<p>Pipeline de scraping + traduction de chapitres.</p>
<fieldset><legend>Lancer un pipeline (scrape → clean → translate → QA → export)</legend>
<input id="r-source" placeholder="source (demo, mangadex)" value="demo">
<input id="r-series" placeholder="id série" value="demo-1">
<input id="r-lang" placeholder="langue cible (fr, en, ...)" value="fr">
@@ -41,7 +31,6 @@ INDEX_HTML = """<!doctype html>
</fieldset>
<pre id="out">résultats ici…</pre>
<script>
async function checkSource(){const s=document.getElementById('cs-source').value;const r=await fetch('/check-source?source='+encodeURIComponent(s));document.getElementById('out').textContent=r.status+'\\n'+JSON.stringify(await r.json(),null,2);}
async function runPipeline(){const g=document.getElementById('r-group').value;const m=document.getElementById('r-max').value;const body={source:document.getElementById('r-source').value,series:document.getElementById('r-series').value,lang:document.getElementById('r-lang').value,mock_llm:document.getElementById('r-mock').checked};if(g)body.group=g;if(m)body.max_chapters=Number(m);document.getElementById('out').textContent='en cours…';const r=await fetch('/run',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)});document.getElementById('out').textContent=r.status+'\\n'+JSON.stringify(await r.json(),null,2);}
</script>
</body></html>
@@ -74,11 +63,6 @@ class Handler(BaseHTTPRequestHandler):
return self._html(200, INDEX_HTML)
if u.path == "/healthz":
return self._json(200, {"status": "ok"})
if u.path == "/check-source":
source = parse_qs(u.query).get("source", [""])[0]
if not source:
return self._json(400, {"error": "paramètre 'source' requis"})
return self._json(200, legal.check_source(source).to_dict())
return self._json(404, {"error": "not found"})
def do_POST(self) -> None:
@@ -107,15 +91,8 @@ class Handler(BaseHTTPRequestHandler):
def serve(host: str = "127.0.0.1", port: int = 8000) -> None:
cfg = os.environ.get("SCALPER_CONFIG")
if cfg:
if Path(cfg).exists():
legal.load_config(cfg)
print(f"registre de sources chargé: {cfg}")
else:
print(f"attention: SCALPER_CONFIG={cfg} introuvable, ignoré")
server = ThreadingHTTPServer((host, port), Handler)
print(f"scalper serve sur http://{host}:{port} (GET /healthz, GET /check-source, POST /run)")
print(f"scalper serve sur http://{host}:{port} (GET /healthz, POST /run)")
try:
server.serve_forever()
except KeyboardInterrupt: