659e4c7e76
Handleidingen 01, 02, 03, 05, 07, 08 met Zelf kiezen-kaders en Maak hem van jou; bijlagen ontwerpkaart, ontwerppatronen, AI-tools in het onderwijs; draaiboek workshop Kennisfestival 23-09-2026; gedeeld bouwscript, extract.py, CC BY-SA 4.0. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
40 lines
1.7 KiB
Python
40 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Haalt een screenshot uit het Claude Code-sessietranscript.
|
|
Gebruik: extract.py <screenshot-id zoals ss_1923g3a1u> <doelpad.jpg>
|
|
Let op: JSONL hieronder wijst naar de Claude Code-sessie van 20 september 2026;
|
|
bij een nieuwe sessie het pad aanpassen."""
|
|
import base64, json, sys
|
|
from pathlib import Path
|
|
|
|
JSONL = Path("/home/guido/.claude/projects/-home-guido-projecten-lexconsultancybv-nl-server/f0263769-3318-4702-826c-1957526cfde0.jsonl")
|
|
|
|
def find(ss_id):
|
|
for line in JSONL.read_text().splitlines():
|
|
if ss_id not in line:
|
|
continue
|
|
rec = json.loads(line)
|
|
content = rec.get("message", {}).get("content", [])
|
|
for block in content if isinstance(content, list) else []:
|
|
if block.get("type") != "tool_result":
|
|
continue
|
|
inner = block.get("content", [])
|
|
if not isinstance(inner, list):
|
|
continue
|
|
# In een browser_batch staan meerdere screenshots in één resultaat:
|
|
# neem het beeld dat direct volgt op de tekst met dit ID.
|
|
for i, b in enumerate(inner):
|
|
if b.get("type") == "text" and ss_id in b.get("text", ""):
|
|
for nb in inner[i + 1:]:
|
|
if nb.get("type") == "image":
|
|
return base64.b64decode(nb["source"]["data"])
|
|
if nb.get("type") == "text" and "ss_" in nb.get("text", ""):
|
|
break
|
|
return None
|
|
|
|
ss_id, dest = sys.argv[1], Path(sys.argv[2])
|
|
data = find(ss_id)
|
|
if not data:
|
|
sys.exit(f"geen beeld gevonden voor {ss_id}")
|
|
dest.write_bytes(data)
|
|
print(f"{dest.name}: {len(data)//1024} kB")
|