83 lines
3.7 KiB
Markdown
83 lines
3.7 KiB
Markdown
---
|
||
name: 内容管理
|
||
description: 文章、图片、视频分表分目录管理;文章正文在库内,图/视频文件在数据目录、库内仅存相对路径。代码分层:db 仓储 / services 业务 / cli 入口。
|
||
version: 2.0.0
|
||
author: 深圳匠厂科技有限公司
|
||
metadata:
|
||
openclaw:
|
||
slug: content-manager
|
||
emoji: "📝"
|
||
category: "通用"
|
||
dependencies:
|
||
required:
|
||
- llm-manager
|
||
auto_install: false
|
||
allowed-tools:
|
||
- bash
|
||
---
|
||
|
||
# 内容管理器(文章 / 图片 / 视频)
|
||
|
||
## 代码结构(MVC 分层)
|
||
|
||
- `scripts/main.py`:仅入口与环境准备(`sys.path`、Windows UTF-8)。
|
||
- `content_manager/cli/`:参数解析与分发(Controller)。
|
||
- `content_manager/services/`:业务编排(调用仓储、llm-manager、文件复制)。
|
||
- `content_manager/db/`:SQLite 连接、建表迁移、按表划分的 **repository**(只做 SQL,不含业务规则)。
|
||
- `content_manager/config.py`:数据根路径、技能数据目录。
|
||
- `content_manager/constants.py`:提示词种子、平台别名等常量。
|
||
|
||
## 数据与表结构
|
||
|
||
- 库路径:`{JIANGCHANG_DATA_ROOT}/{JIANGCHANG_USER_ID}/content-manager/content-manager.db`
|
||
- **文章** 表 `articles`:`title`、`body`、`content_html`、`status`、`source`、`llm_target`、`account_id`、`error_msg`、`extra_json`、时间戳等(正文在库内)。
|
||
- **图片** 表 `images`:仅存 **`file_path`(相对技能数据目录)** 及 `title`、`status`、`source` 等元数据;二进制在 `{…}/content-manager/images/<id>/`。
|
||
- **视频** 表 `videos`:同上,文件在 `{…}/content-manager/videos/<id>/`;可选 `duration_ms`。
|
||
- 提示词相关表:`prompt_templates`、`prompt_template_usage`(供文章 `generate`)。
|
||
|
||
从旧版「TEXT 主键」`articles` 库启动时会自动迁移到新结构。
|
||
|
||
## 常用命令
|
||
|
||
将 `{baseDir}` 换为技能根目录。一级子命令为 **`article` / `image` / `video`**。
|
||
|
||
### 文章
|
||
|
||
```bash
|
||
python {baseDir}/scripts/main.py article list
|
||
python {baseDir}/scripts/main.py article get <id>
|
||
python {baseDir}/scripts/main.py article add --title "标题" --body "正文"
|
||
python {baseDir}/scripts/main.py article add --title "标题" --body-file D:\path\article.md
|
||
python {baseDir}/scripts/main.py article import-json D:\path\articles.json
|
||
python {baseDir}/scripts/main.py article generate 豆包 搜狐号 "RPA降本增效"
|
||
python {baseDir}/scripts/main.py article prompt-list 搜狐号 --limit 20
|
||
python {baseDir}/scripts/main.py article delete <id>
|
||
python {baseDir}/scripts/main.py article feedback <id> published <account_id>
|
||
python {baseDir}/scripts/main.py article save <id或占位> <title> <单行正文>
|
||
```
|
||
|
||
`article get` 输出 JSON:`id`、`title`、`content`、`content_html`、`status` 等。
|
||
|
||
### 图片 / 视频(库内只存路径)
|
||
|
||
```bash
|
||
python {baseDir}/scripts/main.py image add --file D:\a.png [--title "说明"]
|
||
python {baseDir}/scripts/main.py image list
|
||
python {baseDir}/scripts/main.py image get <id>
|
||
python {baseDir}/scripts/main.py image delete <id>
|
||
python {baseDir}/scripts/main.py image feedback <id> published <account_id>
|
||
|
||
python {baseDir}/scripts/main.py video add --file D:\a.mp4 [--title "说明"] [--duration-ms 120000]
|
||
python {baseDir}/scripts/main.py video list
|
||
python {baseDir}/scripts/main.py video get <id>
|
||
python {baseDir}/scripts/main.py video delete <id>
|
||
python {baseDir}/scripts/main.py video feedback <id> failed <account_id> "原因"
|
||
```
|
||
|
||
`image get` / `video get` 的 JSON 含 `file_path`(相对)、`absolute_path`(解析后绝对路径)。
|
||
|
||
## 环境变量
|
||
|
||
- `JIANGCHANG_DATA_ROOT`、`JIANGCHANG_USER_ID`:与 account-manager 一致。
|
||
- `llm-manager` 依赖其自身环境与账号/API Key 配置。
|