This repository has been archived on 2026-08-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
openclaw/skills/kb-zhihu-content/SKILL.md
T

155 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: kb-zhihu-content
description: 知乎内容下载 - 下载视频、提取文章内容
---
# KB Zhihu Content Skill
**kb-zhihu-content** - 下载知乎视频、提取文章内容。
## 什么时候使用
- kb-workflow 步骤 3a:下载知乎视频
- kb-workflow 步骤 3b:提取知乎专栏文章内容
## 功能
- 视频下载(使用 yt-dlp)
- 从 MediaCrawler 数据读取文章内容
- 支持 `ZHIHU_COOKIE` 环境变量
## 环境变量
| 变量名 | 必需 | 说明 |
|--------|------|------|
| `ZHIHU_COOKIE` | 否 | 知乎登录 Cookie |
## 命令
```bash
# 下载视频
python3 zhihu_content.py --id "12345678" --type video --output "/path/to/downloads/"
# 从 MediaCrawler 读取文章内容
python3 zhihu_content.py --type article-from-media \
--input "~/work/MediaCrawler/data/zhihu/json/detail_contents_2026-02-27.json" \
--output "~/work/knowledge-base/data/zhihu/"
# 自动查找最新 MediaCrawler 数据
python3 zhihu_content.py --type article-from-media \
--output "~/work/knowledge-base/data/zhihu/"
```
## 输出格式 Schema
### 必需字段
| 字段 | 类型 | 说明 |
|------|------|------|
| `success` | boolean | 是否成功 |
| `type` | string | 操作类型(video/article) |
### 视频下载特有字段
| 字段 | 类型 | 说明 |
|------|------|------|
| `filepath` | string | 视频文件路径 |
| `filename` | string | 视频文件名 |
### 文章提取特有字段
| 字段 | 类型 | 说明 |
|------|------|------|
| `filepath` | string | 文章文件路径 |
| `filename` | string | 文章文件名 |
| `content_length` | number | 内容长度 |
## 成功示例
### 视频下载
```json
{
"success": true,
"type": "video",
"filename": "zhihu_12345678.mp4",
"filepath": "content/downloads/zhihu_12345678.mp4",
"message": "下载完成"
}
```
### 文章内容提取
```json
{
"success": true,
"type": "article",
"filename": "zhihu_article_如何高效的爬取微信公众号.md",
"filepath": "~/work/knowledge-base/data/zhihu/zhihu_article_如何高效的爬取微信公众号.md",
"content_length": 4563,
"message": "文章内容已导出"
}
```
## 错误示例
### 视频下载失败
```json
{
"success": false,
"type": "video",
"error": "视频不存在或无法访问",
"suggestion": "请检查视频 ID 是否正确"
}
```
### MediaCrawler 数据未找到
```json
{
"success": false,
"type": "article-from-media",
"error": "未找到 MediaCrawler 数据文件",
"suggestion": "请先运行 MediaCrawler 爬取文章"
}
```
### 网络错误
```json
{
"success": false,
"error": "网络请求失败: Connection timeout"
}
```
## 安装
```bash
cp -r kb-zhihu-content/ ~/.openclaw/skills/
pip install yt-dlp aiohttp
```
## 在 kb-workflow 中的使用
```bash
# 步骤 3a:下载知乎视频
python3 ~/.openclaw/skills/kb-zhihu-content/zhihu_content.py \
--id "12345678" --type video \
--output "content/downloads/"
# 注意:知乎视频没有官方字幕,下载后需要进入 Whisper 步骤
# 步骤 3b:提取专栏文章(如果有 MediaCrawler 数据)
python3 ~/.openclaw/skills/kb-zhihu-content/zhihu_content.py \
--type article-from-media \
--output "content/"
```
## 注意事项
- **知乎视频没有官方字幕**:下载后必须进入 Whisper 步骤
- MediaCrawler 需要单独安装和运行
- 部分视频可能需要登录才能下载