fbcc3df2cf
- 新增 shortlink_resolver.py 模块 * 检测 B站短链接(b23.tv)和其他短链接服务 * 提供友好的用户引导信息 * 支持 Playwright 浏览器自动化解析(可选) - 集成到 handler.py * 短链接自动检测和提示 * 智能区分短链接和完整 URL - 更新 add_video.py * 支持短链接解析 * 添加 --playwright 参数启用浏览器解析 - 新增 test_shortlink.py 测试脚本 * 测试单个短链接检测 * 测试多个短链接检测 * 测试混合内容场景 * 所有测试通过 - 更新文档 * SKILL.md: 添加短链接说明 * AUTO_TRIGGER.md: 添加短链接章节 * obsidian-kb-improvements.md: 标记任务2为已完成 功能特点: - 方案A(用户引导):已实现并作为默认行为 - 方案B(浏览器自动化):提供 PlaywrightResolver 类,可选使用 - 方案C(代理池):未实现(复杂度高,收益低) 验收标准达成: ✅ 短链接能够友好处理(显示引导信息) ✅ 用户不会感到困惑 ✅ 支持 b23.tv 和其他短链接服务(检测) ✅ 集成到 handler.py ✅ 测试各种短链接场景
Obsidian KB Skill
多源内容知识库维护系统,支持 Bilibili、YouTube、知乎等平台的内容聚合,智能分类,以及长视频分段分析。
功能特性
- 多源内容聚合: 支持 Bilibili、YouTube、知乎等平台
- 智能收件箱: AI 质量评分,自动分类
- 长视频分段分析: 30分钟+ 视频自动分段处理
- 主题组织: 基于标签的自动主题归类
- Git 自动同步: 自动同步到 Obsidian 知识库
- CLI 命令: 完整的命令行接口
快速开始
安装
# 克隆项目
git clone <repository-url>
cd obsidian-kb
# 安装依赖
pip install -r requirements.txt
# 配置
cp config.example.yaml config.yaml
# 编辑 config.yaml,设置 API key 等
配置
创建 config.yaml:
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
git:
enabled: true
vault_path: ~/ObsidianVault # Obsidian 知识库路径
remote: origin
branch: main
chunking:
enabled: true
chunk_duration_seconds: 900 # 15 分钟分段
long_video_threshold: 1800 # 30 分钟以上视为长视频
sources:
bilibili:
enabled: true
cookie: your-bilibili-cookie # 可选,用于获取字幕
基本使用
# 订阅 Bilibili 收藏夹
/kb-subscribe bilibili:fav:12345678
# 查看收件箱
/kb-inbox
# 处理所有内容
/kb-process --all
# 处理指定内容
/kb-process BV1xx411c7mD
# 跳过内容
/kb-skip BV1xx411c7mD
# 查看状态
/kb-status
# 搜索知识库
/kb-search python tutorial
项目结构
obsidian-kb/
├── src/
│ ├── __init__.py
│ ├── models.py # 数据模型
│ ├── config.py # 配置管理
│ ├── storage.py # 存储管理
│ ├── template_renderer.py # 模板渲染
│ ├── content_chunker.py # 内容分块
│ ├── pipeline.py # 处理管道
│ ├── cli.py # 命令行接口
│ ├── git_sync.py # Git 同步
│ └── sources/
│ ├── __init__.py
│ ├── base.py # 适配器基类
│ └── bilibili.py # Bilibili 适配器
├── templates/
│ ├── light_video.md # 轻量视频模板
│ ├── tutorial_video.md # 教程视频模板
│ ├── article.md # 文章模板
│ └── topic_index.md # 主题索引模板
├── tests/ # 测试
├── config.yaml # 配置文件
└── README.md
模板系统
根据内容类型和时长自动选择模板:
- 轻量视频 (
< 30分钟):light_video.md - 教程视频 (
≥ 30分钟):tutorial_video.md- 包含详细分段、前置知识、常见坑点 - 文章:
article.md
长视频分段策略
| 时长 | 策略 | 分段数 |
|---|---|---|
| < 10分钟 | 直接处理 | 1 |
| 10-30分钟 | 截断处理 | 1 |
| 30-60分钟 | 两段式 | 2 |
| 60分钟+ | 多段式 | 每15分钟一段 |
开发
# 运行测试
pytest tests/
# 运行特定测试
pytest tests/test_models.py
# 覆盖率报告
pytest --cov=src tests/
许可证
MIT License