feat: 添加专栏文章处理支持

- kb_workflow.py: 添加内容类型判断函数
  - is_video_content(): 判断视频内容
  - is_text_content(): 判断文字内容(专栏/问答)
  - is_image_content(): 判断图片内容
  - get_content_handler(): 获取处理方式

- SKILL.md: 完善条件分支逻辑
  - 添加内容类型判断表格
  - 添加专栏文章处理流程说明
  - 添加专栏文章的步骤4.2处理指南
  - 更新子技能清单,添加专栏文章命令
This commit is contained in:
2026-02-16 21:07:26 +08:00
parent 3dc8d246d0
commit 09618f52c5
2 changed files with 116 additions and 0 deletions
+69
View File
@@ -156,6 +156,13 @@ python3 /path/to/zhihu_metadata.py --id "[ID]" --type question --output "${metad
### 步骤 4: 内容下载
> ⚠️ **根据内容类型选择处理方式**:
> - **视频 (video)**:下载字幕/视频
> - **专栏文章 (article)**:提取文字内容(跳过步骤5)
> - **知乎问答/专栏**:提取文字内容(跳过步骤5)
#### 4.1 视频内容处理(type=video)
1. 获取目录路径:
```bash
python3 kb_workflow.py --content_downloads
@@ -176,6 +183,34 @@ python3 /path/to/bilibili_content.py --id "[ID]" --type subtitle-download --outp
> ⚠️ **重要提示**:没有找到官方字幕是**正常的**!很多视频没有自动生成的字幕。不要因为没有字幕就停止工作流,继续执行 Whisper 步骤即可。
#### 4.2 专栏文章处理(type=article/zhuanlan/question)
1. 获取目录路径:
```bash
python3 kb_workflow.py --content
```
2. 启动子代理调用对应平台的 content 技能提取文字:
**B站专栏 (article)**:
```bash
# 提取专栏文字内容
python3 /path/to/bilibili_content.py --id "cv[ID]" --type article --output [content_dir]
# 示例:cv43780186 → id 填 43780186
python3 /path/to/bilibili_content.py --id "43780186" --type article --output [content_dir]
```
**知乎文章/问答**:
```bash
# 知乎问答/专栏提取(需要对应的 content 技能支持)
python3 /path/to/zhihu_content.py --id "[ID]" --type [question|answer|zhuanlan] --output [content_dir]
```
3. 解析输出 JSON,提取文字内容用于深度分析
> ⚠️ **重要**:专栏文章不需要 Whisper 步骤,提取完文字后直接进入步骤 6(深度分析)
### 步骤 5: 语音识别转文字(仅当没有官方字幕时执行)
> ⚠️ **重要**:此步骤仅在**没有官方字幕**时执行。如果有官方字幕,**跳过此步骤**。
@@ -285,15 +320,31 @@ python3 kb_workflow.py --archive-file "[分析报告文件路径]"
|------|--------|----------|------|------|
| 2 | kb-link-parser | `--url "BVxxx"` | `{p}_{id}.link.json` | |
| 3 | kb-bilibili-metadata | `--id "BVxxx" --type video` | `{p}_{id}.meta.json` | |
| 3 | kb-bilibili-metadata | `--id "cvxxx" --type article` | `{p}_{id}.meta.json` | 专栏元数据 |
| 3 | kb-zhihu-metadata | `--id "xxx" --type question` | `{p}_{id}.meta.json` | |
| 4 | kb-bilibili-content | `--id "BVxxx" --type subtitle-download` | `{p}_{id}.srt` | 如果没有字幕是正常的 |
| 4 | kb-bilibili-content | `--id "BVxxx" --type video` | `{p}_{id}.mp4` | 如果需要下载视频 |
| 4 | kb-bilibili-content | `--id "cvxxx" --type article` | `{p}_{id}.txt` | **专栏文章提取文字** |
| 5 | kb-whisper | `--input xxx.mp4 --model base` | `{p}_{id}.json`, `{p}_{id}.txt` | 仅当没有官方字幕时执行 |
| 5 | kb-whisper-diarization | `--input xxx.mp4 --model base --diarize` | `{p}_{id}_diarized.json` | 带说话者分离(需 HF_TOKEN) |
| 6 | kb-deep-analyzer | `--metadata x.meta.json --content x.json --output x.md --provider zhipu --model glm-5` | `{p}_{id}.md` | **使用 g5 模型,必须成功** |
## 条件分支逻辑
### 内容类型判断
链接解析后,根据 `type` 字段判断内容类型:
| type 值 | 内容类型 | 处理方式 |
|---------|---------|---------|
| `video` | 视频 | 下载视频/字幕,可能需要 Whisper |
| `article` | B站专栏 | 直接提取文字内容 |
| `zhuanlan` | 知乎专栏 | 直接提取文字内容 |
| `question` / `answer` | 知乎问答 | 直接提取文字内容 |
| `note` | 小红书 | 下载图片 |
### 视频处理流程(type=video)
```
步骤3: 获取元数据
↓
@@ -316,6 +367,24 @@ python3 kb_workflow.py --archive-file "[分析报告文件路径]"
└─────────────────────────────────────┘
```
### 专栏文章处理流程(type=article/zhuanlan/question)
```
步骤3: 获取元数据
↓
步骤4: 提取专栏/文章文字内容
│ 命令: python3 bilibili_content.py --id "cvxxx" --type article
↓
步骤6: 深度分析(直接使用提取的文字)
↓
┌─────────────────────────────────────┐
│ kb-deep-analyzer 执行结果 │
├─────────────────────────────────────┤
│ success = true → 步骤7(归档) │
│ success = false → ❌ 整个流程失败 │
└─────────────────────────────────────┘
```
> ⚠️ **重要:深度分析失败则整个流程失败**
> - 深度分析必须使用正确的 AI 模型(glm-4.7)完整分析字幕内容
> - 如果 `kb-deep-analyzer` 返回 `success: false`,**必须汇报失败**,不能继续执行后续步骤
+47
View File
@@ -33,6 +33,53 @@ CONTENT_AGENTS = {
}
# ==================== 内容类型判断 ====================
# 需要下载视频/字幕的内容类型
VIDEO_CONTENT_TYPES = {"video"}
# 需要提取文字的内容类型
TEXT_CONTENT_TYPES = {"article", "zhuanlan", "question", "answer"}
# 需要下载图片的内容类型
IMAGE_CONTENT_TYPES = {"note"}
def is_video_content(content_type: str) -> bool:
"""判断是否为视频内容类型"""
return content_type in VIDEO_CONTENT_TYPES
def is_text_content(content_type: str) -> bool:
"""判断是否为文字内容类型(专栏、文章、问答等)"""
return content_type in TEXT_CONTENT_TYPES
def is_image_content(content_type: str) -> bool:
"""判断是否为图片内容类型(小红书等)"""
return content_type in IMAGE_CONTENT_TYPES
def get_content_handler(content_type: str) -> str:
"""
获取内容处理方式
Returns:
"video" - 需要下载视频/字幕
"text" - 需要提取文字
"image" - 需要下载图片
"unknown" - 未知类型
"""
if is_video_content(content_type):
return "video"
elif is_text_content(content_type):
return "text"
elif is_image_content(content_type):
return "image"
else:
return "unknown"
# ==================== 工具函数 ====================
def extract_platform(filename: str) -> str: