-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
52 lines (43 loc) · 1.69 KB
/
cli.py
File metadata and controls
52 lines (43 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
from pathlib import Path
import argparse
from summarizer.config import require_env
from summarizer.summarizer import summarise, MODES
from summarizer.exporter import save_markdown, save_pdf
from summarizer.notion_exporter import push_to_notion
def main():
p = argparse.ArgumentParser(
prog="smart-summarizer",
description="Summarise any web article with multiple output modes."
)
p.add_argument("url")
p.add_argument("-m", "--mode", choices=MODES.__args__, default="detailed",
help="Summary style (default: detailed)")
p.add_argument("--md", metavar="FILE.md", help="write Markdown here")
p.add_argument("--pdf", metavar="FILE.pdf", help="write PDF here")
p.add_argument("--notion", action="store_true", help="export to Notion page")
p.add_argument("--model", default="gpt-4o-mini", help="OpenAI model")
args = p.parse_args()
summary = summarise(args.url, mode=args.mode, model=args.model)
# Debug prints
print(f"🧪 URL: {args.url}")
print(f"🧪 Mode: {args.mode}")
print(f"🧪 Model: {args.model}")
print(f"🧪 Meta title: {summary['meta'].get('title', 'No title')}\n")
print("\n— SUMMARY —\n")
print(summary["summary"])
if args.md:
save_markdown(summary, args.md)
print(f"✓ Markdown saved → {args.md}")
if args.pdf:
save_pdf(summary, args.pdf)
print(f"✓ PDF saved → {args.pdf}")
if args.notion:
push_to_notion(
summary,
token=require_env("NOTION_TOKEN"),
parent_page_id=require_env("NOTION_PAGE_ID"),
)
print("✓ Posted to Notion")
if __name__ == "__main__":
main()