Fix: H1+Meta aus Joomla-Body strippen, Bild-Auto-Delete entfernt

- H1 und <p class=meta> werden vor dem Senden an Joomla aus dem Body gefiltert
  (Daniel 19.06.: Titel+Lesezeit dürfen nicht im Fließtext landen)
- os.remove() für Bilder nach erfolgreichem Publish entfernt
  (Bilder bleiben auf Disk erhalten für spätere Referenz/Live-Schaltung)
This commit is contained in:
Hermes Agent
2026-06-19 09:17:41 +02:00
parent 0f787589fe
commit 889acd8c6d
+9 -8
View File
@@ -1112,6 +1112,12 @@ h1{color:#c0392b;}p{color:#888;}</style></head>
body_match = re.search(r'(?:</header>|</head>)(.*?)(?:<footer|<div class="quellen"|</body)', html_content, re.DOTALL)
article_body = body_match.group(1) if body_match else html_content
# ── Strip H1 + Meta-Zeile aus dem Body ─────────────────
# Daniel 19.06.: Titel und Lesezeit-Zeile dürfen NICHT im
# Fließtext landen — sie werden von Joomla separat gerendert.
article_body = re.sub(r'<h1[^>]*>.*?</h1>\s*', '', article_body, flags=re.DOTALL)
article_body = re.sub(r'<p\s+class="meta"[^>]*>.*?</p>\s*', '', article_body, flags=re.DOTALL)
# Extract Joomla ID if present (for updates)
jid_match = re.search(r'<meta\s+name="joomla-id"\s+content="(\d+)"', html_content, re.IGNORECASE)
joomla_id = jid_match.group(1) if jid_match else None
@@ -1297,15 +1303,10 @@ h1{color:#c0392b;}p{color:#888;}</style></head>
with open(filepath, "w", encoding="utf-8") as f:
f.write(html_content)
# ── Auto-delete associated images ───────────────────────
# ── Image mapping cleanup: remove association but keep files ──
# Daniel 19.06.: Bilder NICHT löschen — sie werden für
# spätere Live-Schaltungen und Referenz benötigt.
if fname in img_map:
for img_path in img_map[fname]:
if os.path.exists(img_path):
try:
os.remove(img_path)
images_deleted_total += 1
except OSError as e:
errors.append(f"{fname}: Bild {img_path} konnte nicht gelöscht werden: {e}")
del img_map[fname]
save_image_map(img_map)