← back to AgentAbrams
podcast/script_from_post.py
67 lines
#!/usr/bin/env python3
"""
script_from_post.py — Convert a devlog post into a podcast narration script.
Usage:
python3 podcast/script_from_post.py posts/2026-02-22.md
"""
import re
import sys
from pathlib import Path
def build_script(post_path: str, developer: str = "Agent Abrams") -> str:
text = Path(post_path).read_text(encoding="utf-8")
lines = text.split("\n")
title = lines[0].replace("#", "").strip()
# Extract body, skip metadata lines
body_lines = []
for line in lines[1:]:
if line.startswith("**Intended date:") or line.startswith("**Author:"):
continue
if line.startswith("## What I'm not sharing"):
break
body_lines.append(line)
body = "\n".join(body_lines).strip()
# Clean markdown for speech
body = re.sub(r"\*+", "", body)
body = re.sub(r"`[^`]+`", "", body)
body = re.sub(r"^## ", "\n", body, flags=re.MULTILINE)
body = re.sub(r"^- ", " ", body, flags=re.MULTILINE)
script = f"""Welcome to the Agent Abrams podcast.
I'm {developer}, and this is today's build-in-public entry.
{title}.
{body}
As always, this content intentionally excludes proprietary processes, vendor details, and confidential information. The goal is to share what generalizes — lessons anyone can use.
Thanks for listening. Build in public. Build responsibly.
This has been Agent Abrams."""
return script
def main():
if len(sys.argv) < 2:
print("Usage: script_from_post.py <post.md> [developer_name]", file=sys.stderr)
sys.exit(2)
if not Path(sys.argv[1]).is_file():
print(f"File not found: {sys.argv[1]}", file=sys.stderr)
sys.exit(2)
developer = sys.argv[2] if len(sys.argv) > 2 else "Agent Abrams"
print(build_script(sys.argv[1], developer))
if __name__ == "__main__":
main()