fix(tts): exclude donations and accounting entries
This commit is contained in:
@@ -24,6 +24,8 @@ if ($action === 'get') {
|
|||||||
'title' => $p->post_title,
|
'title' => $p->post_title,
|
||||||
'content' => $p->post_content,
|
'content' => $p->post_content,
|
||||||
'status' => $p->post_status,
|
'status' => $p->post_status,
|
||||||
|
'post_type' => $p->post_type,
|
||||||
|
'post_name' => $p->post_name,
|
||||||
'author' => (int)$p->post_author,
|
'author' => (int)$p->post_author,
|
||||||
], JSON_UNESCAPED_UNICODE));
|
], JSON_UNESCAPED_UNICODE));
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|||||||
@@ -93,7 +93,15 @@ def get_post_text(pid):
|
|||||||
check=True, capture_output=True)
|
check=True, capture_output=True)
|
||||||
subprocess.run(["docker", "cp", f"{CONTAINER}:/tmp/fea_es.json", "/tmp/fea_es.json"], check=True)
|
subprocess.run(["docker", "cp", f"{CONTAINER}:/tmp/fea_es.json", "/tmp/fea_es.json"], check=True)
|
||||||
d = json.load(open("/tmp/fea_es.json"))
|
d = json.load(open("/tmp/fea_es.json"))
|
||||||
raw = re.sub(r"(?i)</p>|<br\s*/?>|</h[1-6]>", "\n", d["content"])
|
# Hard gate: pages and operational/accounting entries are never TTS input.
|
||||||
|
# This also protects explicit --ids queues, which bypass author-backlog SQL.
|
||||||
|
raw_content = d.get("content", "")
|
||||||
|
blocked_markers = ("fea-don-wrap", "fea-ledger", "Haz tu donación")
|
||||||
|
if d.get("post_type") != "post":
|
||||||
|
raise ValueError(f"post #{pid} no es un artículo (post_type={d.get('post_type')!r}); TTS excluido")
|
||||||
|
if d.get("post_name") == "numeros" or any(marker in raw_content for marker in blocked_markers):
|
||||||
|
raise ValueError(f"post #{pid} es contenido de cuentas/donaciones; TTS excluido")
|
||||||
|
raw = re.sub(r"(?i)</p>|<br\s*/?>|</h[1-6]>", "\n", raw_content)
|
||||||
raw = re.sub(r"<[^>]+>", "", raw)
|
raw = re.sub(r"<[^>]+>", "", raw)
|
||||||
raw = re.sub(r"\[[^\]]+\]", "", raw)
|
raw = re.sub(r"\[[^\]]+\]", "", raw)
|
||||||
raw = html.unescape(raw)
|
raw = html.unescape(raw)
|
||||||
|
|||||||
Reference in New Issue
Block a user