From eb593270861e6e4f0e5b7dde6d7986e3a9b1d594 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Thu, 18 Jun 2026 22:39:10 +0200 Subject: [PATCH] =?UTF-8?q?VG-Wort:=20Z=C3=A4hlmarken-Pool-Integration=20v?= =?UTF-8?q?ia=20subprocess?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - _handle_publish() ruft vgwort_pool.py get auf - Pixel-Tag auto in articletext vor eingebaut - Live getestet: Pixel korrekt (15371, vg09.met.vgwort.de) - Pool-Script: ~/.hermes/vgwort_pool.py --- article_server.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/article_server.py b/article_server.py index 2296e08..1efabc5 100644 --- a/article_server.py +++ b/article_server.py @@ -948,13 +948,32 @@ h1{color:#c0392b;}p{color:#888;} # Generate alias from title alias = re.sub(r'[^a-z0-9]+', '-', title.lower().strip())[:100] - # ── Inject VG-Wort pixel ─────────────────────────────────── - if VG_WORT_PIXEL_HTML and VG_WORT_COUNTER_ID: - # Insert pixel right before closing or at the end of body - if '' in article_body: - article_body = article_body.replace('', f'{VG_WORT_PIXEL_HTML}\n') + # ── VG-Wort Zählmarke aus Pool holen & einbauen ───────── + vgwort_pixel_html = "" + try: + import subprocess + result = subprocess.run( + ["python3", os.path.expanduser("~/.hermes/vgwort_pool.py"), "get"], + capture_output=True, text=True, timeout=30 + ) + if result.returncode == 0: + pixel_data = json.loads(result.stdout) + if pixel_data.get("ok"): + vgwort_pixel_html = pixel_data.get("pixel_html", "") + print(f"[VG-Wort] Zählmarke {pixel_data.get('public_id')} eingebaut, " + f"Pool: {pixel_data.get('pool_remaining')} übrig", flush=True) + else: + print(f"[VG-Wort] FEHLER: {pixel_data.get('error', 'unbekannt')}", flush=True) else: - article_body = article_body.rstrip() + f'\n{VG_WORT_PIXEL_HTML}\n' + print(f"[VG-Wort] Pool-Script fehlgeschlagen: {result.stderr}", flush=True) + except Exception as e: + print(f"[VG-Wort] Ausnahme: {e}", flush=True) + + if vgwort_pixel_html: + if '' in article_body: + article_body = article_body.replace('', f'{vgwort_pixel_html}\n') + else: + article_body = article_body.rstrip() + f'\n{vgwort_pixel_html}\n' # ── Joomla API call ───────────────────────────────────────── headers = {