b3b6b702d1
- publish_gatekeeper.py (neues Gatekeeper-System) - 4 Premium-Artikel: Veggie Match, Berlin 1960, Wild Tiled West, Scream Park - Alle kumulierten Artikel, Scripts, Medien und Caches
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
import urllib.request, json, re
|
|
|
|
token = open('/home/hermes/.hermes/joomla_token.txt').read().strip()
|
|
|
|
with open('/home/hermes/workspace/artikel_catan_usa_2026_clean.html') as f:
|
|
text = f.read()
|
|
|
|
parts = text.split('<hr id="system-readmore" />', 1)
|
|
intro = parts[0].strip() if len(parts) > 1 else text[:500]
|
|
full = parts[1].strip() if len(parts) > 1 else ''
|
|
|
|
req = urllib.request.Request(
|
|
'https://www.brettspiel-news.de/api/index.php/v1/content/articles/15425',
|
|
headers={'Accept':'application/vnd.api+json','X-Joomla-Token':token})
|
|
r = json.loads(urllib.request.urlopen(req, timeout=10).read())
|
|
title = r['data']['attributes']['title']
|
|
|
|
payload = {'title': title, 'introtext': intro, 'fulltext': full}
|
|
req2 = urllib.request.Request(
|
|
'https://www.brettspiel-news.de/api/index.php/v1/content/articles/15425',
|
|
data=json.dumps(payload, ensure_ascii=False).encode(),
|
|
headers={'Accept':'application/vnd.api+json','Content-Type':'application/json','X-Joomla-Token':token},
|
|
method='PATCH')
|
|
|
|
try:
|
|
resp = urllib.request.urlopen(req2, timeout=15)
|
|
r2 = json.loads(resp.read())
|
|
a = r2['data']['attributes']
|
|
t = a.get('text','')
|
|
has_style = '<style' in t
|
|
has_bsn = 'bsn-infobox' in t
|
|
print(f"HTTP 200 | State={a['state']}")
|
|
print(f"<style> im Text: {has_style}")
|
|
print(f"bsn-infobox: {has_bsn}")
|
|
print(f"Textlaenge: {len(t)} chars")
|
|
except urllib.error.HTTPError as e:
|
|
print(f"HTTP {e.code}: {e.read().decode()[:300]}")
|