08f7c9f26c
- 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)
164 lines
2.9 KiB
Markdown
164 lines
2.9 KiB
Markdown
# Obsidian KB - 快速开始指南
|
||
|
||
## 安装依赖
|
||
|
||
```bash
|
||
cd /home/admin/.openclaw/workspace/skills/obsidian-kb
|
||
pip install -r requirements.txt
|
||
```
|
||
|
||
## 配置
|
||
|
||
创建 `config.yaml` 文件:
|
||
|
||
```yaml
|
||
ai:
|
||
provider: openai
|
||
model: gpt-4
|
||
api_key: your-api-key-here
|
||
|
||
git:
|
||
enabled: false
|
||
vault_path: ~/Documents/Obsidian/KB
|
||
auto_push: false
|
||
commit_message_template: "Add note: {title}"
|
||
|
||
obsidian:
|
||
vault_path: ~/Documents/Obsidian/KB
|
||
notes_folder: Notes
|
||
|
||
sources:
|
||
bilibili:
|
||
enabled: true
|
||
cookie: null
|
||
extraction:
|
||
headless: true
|
||
timeout: 30
|
||
```
|
||
|
||
## 使用方式
|
||
|
||
### 1. 命令行
|
||
|
||
```bash
|
||
# 处理单个视频
|
||
python3 -m main_pipeline BV1MnFNz5EDL
|
||
|
||
# 处理视频并同步到 Git
|
||
python3 -m main_pipeline BV1MnFNz5EDL --git
|
||
|
||
# 使用 Handler
|
||
python3 handler.py process BV1MnFNz5EDL
|
||
|
||
# 检测链接
|
||
python3 handler.py detect "https://www.bilibili.com/video/BV1xx411c7mD"
|
||
```
|
||
|
||
### 2. Python 代码
|
||
|
||
```python
|
||
from main_pipeline import MainPipeline
|
||
from src.config import get_config
|
||
|
||
# 创建主流程
|
||
config = get_config()
|
||
pipeline = MainPipeline(config=config, enable_git_sync=False)
|
||
|
||
# 处理视频
|
||
result = pipeline.process_video("BV1MnFNz5EDL")
|
||
|
||
if result['success']:
|
||
print("处理成功!")
|
||
print(result['message'])
|
||
else:
|
||
print(f"处理失败: {result['error']}")
|
||
```
|
||
|
||
### 3. 使用 Handler 接口
|
||
|
||
```python
|
||
from handler import process_video_full
|
||
|
||
# 处理视频
|
||
success, message = process_video_full("BV1MnFNz5EDL", enable_git_sync=False)
|
||
|
||
if success:
|
||
print(message)
|
||
else:
|
||
print(f"失败: {message}")
|
||
```
|
||
|
||
## 测试
|
||
|
||
```bash
|
||
# 验证代码结构(不需要依赖)
|
||
python3 verify_integration.py
|
||
|
||
# 运行完整测试(需要所有依赖)
|
||
python3 test_integration.py
|
||
```
|
||
|
||
## 输出
|
||
|
||
处理成功后,Obsidian 笔记会生成在:
|
||
|
||
```
|
||
{vault_path}/videos/bilibili/{author}/{date}_{title}.md
|
||
```
|
||
|
||
例如:
|
||
```
|
||
~/Documents/Obsidian/KB/videos/bilibili/某UP主/2026-02-07_视频标题.md
|
||
```
|
||
|
||
## 日志
|
||
|
||
日志会记录到 `obsidian_kb.log` 文件,包括:
|
||
- 每个步骤的开始和完成
|
||
- 提取的视频信息
|
||
- 分析结果摘要
|
||
- 错误信息和堆栈
|
||
|
||
## 数据流
|
||
|
||
```
|
||
BV号/URL
|
||
↓
|
||
提取 (BilibiliExtractor)
|
||
↓
|
||
分析 (DeepAnalyzer)
|
||
↓
|
||
分片 (ContentChunker)
|
||
↓
|
||
输出 (ObsidianWriter)
|
||
↓
|
||
同步 (GitSync) [可选]
|
||
↓
|
||
Obsidian 笔记
|
||
```
|
||
|
||
## 常见问题
|
||
|
||
### Q: 如何启用 Git 同步?
|
||
|
||
A: 设置 `git.enabled: true` 并在调用时使用 `enable_git_sync=True`。
|
||
|
||
### Q: 如何配置 AI?
|
||
|
||
A: 在 `config.yaml` 中设置 `ai.api_key`。
|
||
|
||
### Q: 无字幕怎么办?
|
||
|
||
A: 系统会降级处理,使用 description 或默认标签,不会崩溃。
|
||
|
||
### Q: 如何批量处理?
|
||
|
||
A: 参见 `example_usage.py` 中的 `example_4_batch_processing()`。
|
||
|
||
## 更多信息
|
||
|
||
- **Checkpoint 6 完成报告**: `CHECKPOINT_6.md`
|
||
- **使用示例**: `example_usage.py`
|
||
- **测试脚本**: `test_integration.py`
|
||
- **验证脚本**: `verify_integration.py`
|