pdf-capa-code
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill: Montagem de PDFs com Capa — VDE Concursos (Claude Code)
Skill:带封面的PDF组装 — VDE Concursos(Claude Code)
Referência completa (casos extremos, troubleshooting, decisões de design):references/complete-skill.md
完整参考(极端情况、故障排查、设计决策):references/complete-skill.md
Configuração
配置
yaml
SECOES: ["Teoria Sistematizada", "Caderno de Lei"]
RADICAL_FINALIZADOS: "FINALIZADO" # matching case-insensitive, sem 's'
RADICAL_DESTINO: "VERSÃO FINAL" # ou "versao final"
PREFIXO_CAPA: "#CAPA" # PDF nativo no Driveyaml
SECOES: ["Teoria Sistematizada", "Caderno de Lei"]
RADICAL_FINALIZADOS: "FINALIZADO" # 不区分大小写匹配,不带's'
RADICAL_DESTINO: "VERSÃO FINAL" # 或 "versao final"
PREFIXO_CAPA: "#CAPA" # Drive 中的原生 PDF 文件Pré-requisitos
前置要求
bash
gws --version && gws auth status 2>&1token_validtruereferences/complete-skill.mdSempre incluir nos params do gws:"supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives"
bash
gws --version && gws auth status 2>&1token_validtruereferences/complete-skill.mdgws 的参数中请始终包含:"supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives"
Execução
执行步骤
1 — Extrair folder ID da URL
1 — 从 URL 中提取文件夹 ID
https://drive.google.com/drive/u/1/folders/ABC123 → ID = ABC123https://drive.google.com/drive/u/1/folders/ABC123 → ID = ABC1232 — Listar subpastas da disciplina
2 — 列出学科的子文件夹
bash
gws drive files list --params '{"q": "\"FOLDER_ID\" in parents and mimeType=\"application/vnd.google-apps.folder\"", "supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives", "fields": "files(id,name)"}' 2>&1Filtrar por e (case-insensitive).
"teoria sistematizada""caderno de lei"bash
gws drive files list --params '{"q": "\"FOLDER_ID\" in parents and mimeType=\"application/vnd.google-apps.folder\"", "supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives", "fields": "files(id,name)"}' 2>&1筛选出 和 (不区分大小写)。
"teoria sistematizada""caderno de lei"3 — Por seção: coletar IDs (repetir para cada seção)
3 — 按章节收集 ID(每个章节重复执行)
a) Subpastas internas:
bash
gws drive files list --params '{"q": "\"SECAO_ID\" in parents and mimeType=\"application/vnd.google-apps.folder\"", "supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives", "fields": "files(id,name)"}' 2>&1- →
FINALIZADO_IDcontémname.lower()"finalizado" - →
VERSAO_FINAL_IDcontémname.lower()ou"versão final""versao final"
b) Capa (buscar na raiz da seção; se o usuário indicou que está no FINALIZADO, usar ):
capa_id: nullbash
gws drive files list --params '{"q": "\"SECAO_ID\" in parents and name contains \"#CAPA\" and mimeType=\"application/pdf\"", "supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives", "fields": "files(id,name)"}' 2>&1c) Documentos em FINALIZADO:
bash
gws drive files list --params '{"q": "\"FINALIZADO_ID\" in parents and (mimeType=\"application/vnd.google-apps.document\" or mimeType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\")", "supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives", "fields": "files(id,name,mimeType)"}' 2>&1d) Arquivos já na VERSÃO FINAL:
bash
gws drive files list --params '{"q": "\"VERSAO_FINAL_ID\" in parents", "supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives", "fields": "files(id,name)"}' 2>&1a) 内部子文件夹:
bash
gws drive files list --params '{"q": "\"SECAO_ID\" in parents and mimeType=\"application/vnd.google-apps.folder\"", "supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives", "fields": "files(id,name)"}' 2>&1- →
FINALIZADO_ID包含name.lower()"finalizado" - →
VERSAO_FINAL_ID包含name.lower()或"versão final""versao final"
b) 封面(在章节根目录搜索;如果用户说明封面在 FINALIZADO 文件夹中,则设置 ):
capa_id: nullbash
gws drive files list --params '{"q": "\"SECAO_ID\" in parents and name contains \"#CAPA\" and mimeType=\"application/pdf\"", "supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives", "fields": "files(id,name)"}' 2>&1c) FINALIZADO 文件夹中的文档:
bash
gws drive files list --params '{"q": "\"FINALIZADO_ID\" in parents and (mimeType=\"application/vnd.google-apps.document\" or mimeType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\")", "supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives", "fields": "files(id,name,mimeType)"}' 2>&1d) 已存放在 VERSÃO FINAL 文件夹中的文件:
bash
gws drive files list --params '{"q": "\"VERSAO_FINAL_ID\" in parents", "supportsAllDrives": true, "includeItemsFromAllDrives": true, "corpora": "allDrives", "fields": "files(id,name)"}' 2>&14 — Executar o script (repetir para cada seção)
4 — 执行脚本(每个章节重复执行)
Copiar o script (só na primeira seção):
bash
cp '<SKILL_DIR>/scripts/process_batch.py' /tmp/process_batch.pyEscrever o config e executar:
bash
python3 -c "
import json
config = {
'capa_id': 'ID_DA_CAPA', # null → script busca #CAPA em capa_fallback_folder_id
'capa_fallback_folder_id': 'FINALIZADO_ID',
'versao_final_id': 'ID_DA_VERSAO_FINAL',
'existing_files': ['arquivo1.pdf'],
'docs': [
{'id': 'DOC_ID', 'name': '1. Nome', 'mimeType': 'application/vnd.google-apps.document'}
]
}
open('/tmp/batch_config_SECAO_ID.json', 'w').write(json.dumps(config, ensure_ascii=False, indent=2))
"
python3 /tmp/process_batch.py /tmp/batch_config_SECAO_ID.json 2>&1复制脚本(仅首次处理章节时需要):
bash
cp '<SKILL_DIR>/scripts/process_batch.py' /tmp/process_batch.py写入配置并执行:
bash
python3 -c "
import json
config = {
'capa_id': 'ID_DA_CAPA', # null → 脚本会在 capa_fallback_folder_id 中搜索 #CAPA
'capa_fallback_folder_id': 'FINALIZADO_ID',
'versao_final_id': 'ID_DA_VERSAO_FINAL',
'existing_files': ['arquivo1.pdf'],
'docs': [
{'id': 'DOC_ID', 'name': '1. Nome', 'mimeType': 'application/vnd.google-apps.document'}
]
}
open('/tmp/batch_config_SECAO_ID.json', 'w').write(json.dumps(config, ensure_ascii=False, indent=2))
"
python3 /tmp/process_batch.py /tmp/batch_config_SECAO_ID.json 2>&15 — Resultado consolidado
5 — 汇总结果
Disciplina · DD/MM/AAAA
📚 Teoria Sistematizada (N docs)
✓ X enviados · ○ Y já existiam
📚 Caderno de Lei (N docs)
✓ X enviadosErros (): listar causa e oferecer reprocessar apenas os que falharam.
✗Disciplina · DD/MM/AAAA
📚 Teoria Sistematizada (N docs)
✓ X 已提交 · ○ Y 已存在
📚 Caderno de Lei (N docs)
✓ X 已提交错误():列出错误原因,并提供仅重新处理失败项的选项。
✗Erros frequentes
常见错误
| Sintoma | Ação rápida |
|---|---|
| |
| |
| |
| Capa não encontrada | Nome começa com |
| Verificar acesso de Editor no Drive |
Ver e para casos avançados.
references/troubleshooting.mdreferences/complete-skill.md| 现象 | 快速解决方法 |
|---|---|
| |
| |
| |
| 未找到封面 | 文件名是否以 |
| 检查 Drive 的编辑权限 |
如需处理高级情况,请查看 和 。
references/troubleshooting.mdreferences/complete-skill.md