Google Slides
Uses the gog CLI for basic operations and scripts/slides.py for advanced edits (adding/editing slide content via the Slides API).
Auth Check
Before any Slides operation, verify auth is working:
gog slides info <any-presentation-id> --account david@hml.tech
If it fails, re-auth: INLINECODE2
Core Commands (via gog)
CODEBLOCK1
Adding/Editing Slide Content (via scripts/slides.py)
For adding text slides, batch updates, and reading full content, use scripts/slides.py.
CODEBLOCK2
Building a Deck from Scratch
Typical workflow:
- 1. Create presentation:
gog slides create "Title" --json → get INLINECODE5 - Add slides one by one using INLINECODE6
- For rich content (images, shapes, formatting), write batch requests to a JSON file and run INLINECODE7
- Export: INLINECODE8
For complex batch requests (images, shapes, text formatting), see references/batch_requests.md.
Getting Presentation ID
From a Google Slides URL:
INLINECODE10
Notes
- -
gog slides uses the Drive API under the hood (no separate Slides scope needed) - INLINECODE12 uses the Google Slides API directly and requires working gog auth tokens
- Set
GOG_ACCOUNT=david@hml.tech in env to skip --account flag
技能名称: google-slides
详细描述:
Google Slides
使用 gog CLI 进行基本操作,通过 scripts/slides.py 进行高级编辑(通过 Slides API 添加/编辑幻灯片内容)。
认证检查
在执行任何 Slides 操作前,请确认认证是否正常:
bash
gog slides info <任意演示文稿ID> --account david@hml.tech
如果失败,请重新认证:gog auth add david@hml.tech --services gmail,calendar,drive,docs,sheets,contacts,tasks,people
核心命令(通过 gog)
bash
创建新的空白演示文稿
gog slides create 我的演示文稿 --account david@hml.tech --json
获取演示文稿信息(幻灯片数量、标题等)
gog slides info
--account david@hml.tech --json
导出为 PDF
gog slides export --format pdf --out /tmp/deck.pdf --account david@hml.tech
导出为 PPTX
gog slides export --format pptx --out /tmp/deck.pptx --account david@hml.tech
复制演示文稿(例如,使用模板)
gog slides copy 副本标题 --account david@hml.tech --json
添加/编辑幻灯片内容(通过 scripts/slides.py)
如需添加文本幻灯片、批量更新和读取完整内容,请使用 scripts/slides.py。
bash
添加包含标题和项目符号正文的文本幻灯片
python3 scripts/slides.py add-slide \
--title 幻灯片标题 \
--body • 项目符号一\n• 项目符号二
在指定位置添加幻灯片(从0开始索引)
python3 scripts/slides.py add-slide --title 介绍 --insert-at 0
从 JSON 文件执行任意批量更新请求
python3 scripts/slides.py batch requests.json
通过脚本导出
python3 scripts/slides.py export --format pdf --out /tmp/deck.pdf
列出评论及其锚点(例如,所在幻灯片)
python3 scripts/slides.py list-comments
解决评论,并可选择留下回复消息
python3 scripts/slides.py resolve-comment --reply 已修复!
从头构建演示文稿
典型工作流程:
- 1. 创建演示文稿:gog slides create 标题 --json → 获取 presentationId
- 使用 scripts/slides.py add-slide 逐一添加幻灯片
- 对于丰富内容(图片、形状、格式),将批量请求写入 JSON 文件并运行 scripts/slides.py batch
- 导出:gog slides export --format pdf --out /tmp/deck.pdf
对于复杂的批量请求(图片、形状、文本格式),请参阅 references/batch_requests.md。
获取演示文稿 ID
从 Google Slides URL 获取:
https://docs.google.com/presentation/d//edit
注意事项
- - gog slides 底层使用 Drive API(无需单独的 Slides 作用域)
- scripts/slides.py 直接使用 Google Slides API,需要有效的 gog 认证令牌
- 在环境变量中设置 GOG_ACCOUNT=david@hml.tech 可省略 --account 参数