feat: integrate bilibili-extractor into obsidian-kb

- Add extractors layer with BilibiliExtractor (Playwright stealth mode)
- Add outputs layer with ObsidianWriter and GitSync
- Implement subtitle/no-subtitle graceful degradation
- Update config with output and bilibili extraction settings
- Complete integration pipeline: extract → process → output → sync
- Add comprehensive tests (100% pass rate)
- Update documentation (SKILL.md, README.md, requirements.txt)
This commit is contained in:
OpenClaw Agent
2026-02-07 13:07:43 +08:00
parent ceeeb0f84c
commit 08f7c9f26c
29 changed files with 5824 additions and 45 deletions
+77 -1
View File
@@ -1,12 +1,14 @@
# Obsidian KB Skill
多源内容知识库维护系统,支持 Bilibili、YouTube、知乎等平台的内容聚合,智能分类,以及长视频分段分析。
多源内容知识库维护系统,整合了 bilibili-extractor,支持 Bilibili、YouTube、知乎等平台的内容聚合,智能分类,以及长视频分段分析。
## 功能特性
- **多源内容聚合**: 支持 Bilibili、YouTube、知乎等平台
- **增强型 Bilibili 提取**: 使用 Playwright 绕过反爬检测,支持字幕和弹幕提取
- **智能收件箱**: AI 质量评分,自动分类
- **长视频分段分析**: 30分钟+ 视频自动分段处理
- **无字幕处理**: 智能处理无字幕视频,基于元数据生成内容
- **主题组织**: 基于标签的自动主题归类
- **Git 自动同步**: 自动同步到 Obsidian 知识库
- **CLI 命令**: 完整的命令行接口
@@ -33,33 +35,84 @@ cp config.example.yaml config.yaml
创建 `config.yaml`:
```yaml
# AI 配置
ai:
provider: openai
model: gpt-4
api_key: your-api-key-here # 或设置 OPENAI_API_KEY 环境变量
# 存储配置
storage:
inbox_dir: inbox
topics_dir: topics
data_dir: data
# 输出配置
output:
format: markdown # 输出格式
encoding: utf-8
include_timestamp: true # 包含时间戳
include_source: true # 包含源链接
# Git 同步配置
git:
enabled: true
vault_path: ~/ObsidianVault # Obsidian 知识库路径
remote: origin
branch: main
auto_commit: true
# 分段配置
chunking:
enabled: true
chunk_duration_seconds: 900 # 15 分钟分段
long_video_threshold: 1800 # 30 分钟以上视为长视频
# 数据源配置
sources:
bilibili:
enabled: true
cookie: your-bilibili-cookie # 可选,用于获取字幕
# Bilibili 提取器配置
bilibili_extraction:
use_playwright: true # 使用 Playwright 绕过检测
headless: true # 无头模式
cookie_file: '' # Cookie 文件路径 (可选)
enable_subtitle: true # 启用字幕提取
subtitle_language: zh-CN # 字幕语言
enable_danmaku: false # 启用弹幕提取
timeout_seconds: 30 # 超时时间
max_retries: 3 # 最大重试次数
```
### 首次使用
1. **获取 Bilibili Cookie (可选但推荐)**
为了更好的字幕提取体验,建议设置 Bilibili Cookie:
- 在浏览器中登录 Bilibili
- 打开开发者工具 (F12)
- 切换到 Network 标签
- 刷新页面,找到任意请求
- 复制 `Cookie` 头的值
- 将其粘贴到配置文件的 `bilibili.cookie` 字段
2. **初始化 Playwright (首次使用需要)**
```bash
# 安装 Playwright 浏览器
playwright install chromium
```
3. **测试提取器**
```bash
# 测试 Bilibili 提取器
python -c "from obsidian_kb.extractors.bilibili import BilibiliExtractor; e = BilibiliExtractor(); print(e.extract_video('https://www.bilibili.com/video/BV1xx411c7mD'))"
```
### 基本使用
```bash
@@ -85,6 +138,29 @@ sources:
/kb-search python tutorial
```
### 提取器特性
**无字幕处理:**
系统会自动处理没有字幕的视频:
- 使用视频标题、描述和标签生成内容
- AI 分析视频元数据生成摘要
- 在笔记中标注"无字幕"状态
**字幕提取:**
支持多种字幕源:
- CC 字幕 (官方字幕)
- AI 字幕 (自动生成)
- 自动选择最佳字幕源
**反爬检测:**
使用 Playwright 绕过 Bilibili 的反爬机制:
- 无头模式运行
- 自动重试机制
- 可配置超时时间
## 项目结构
```