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-link-parser/SKILL.md
T

3.8 KiB

name, description
name description
kb-link-parser 链接解析器 - 从各平台 URL 提取平台类型、内容类型和 ID

KB Link Parser Skill

kb-link-parser - 从各种平台 URL 中提取和解析 ID。

什么时候使用

  • kb-workflow 步骤 1:解析用户提供的链接
  • 需要判断链接属于哪个平台、什么类型的内容

功能

  • 多平台支持:Bilibili、YouTube、知乎、小红书
  • 短链接解析:b23.tv、xhslink.com 等
  • 多种内容类型:video、article、question、answer 等
  • 批量处理支持
  • JSON 输出格式

命令

# 解析单个 URL
python3 link-parser.py --url "https://www.bilibili.com/video/BV1xx411c7mD"

# 批量处理
python3 link-parser.py --batch urls.txt --output results.json

# 指定输出格式
python3 link-parser.py --url "..." --format json

输出格式 Schema

必需字段

字段 类型 说明
success boolean 是否解析成功
platform string 平台名称(成功时必需)
type string 内容类型(成功时必需)
id string 内容 ID(成功时必需)
error string 错误信息(失败时必需)

可选字段

字段 类型 说明
filename string 建议的文件名
message string 描述信息

成功示例

B站视频

{
  "success": true,
  "platform": "bilibili",
  "type": "video",
  "id": "BV1xx411c7mD",
  "filename": "bilibili_BV1xx411c7mD.link.json",
  "message": "URL解析成功"
}

B站专栏

{
  "success": true,
  "platform": "bilibili",
  "type": "article",
  "id": "cv43780186",
  "filename": "bilibili_cv43780186.link.json",
  "message": "URL解析成功"
}

知乎问答

{
  "success": true,
  "platform": "zhihu",
  "type": "question",
  "id": "266309957",
  "filename": "zhihu_266309957.link.json",
  "message": "URL解析成功"
}

知乎专栏文章

{
  "success": true,
  "platform": "zhihu",
  "type": "zhuanlan",
  "id": "1894054073625461813",
  "filename": "zhihu_1894054073625461813.link.json",
  "message": "URL解析成功"
}

知乎视频

{
  "success": true,
  "platform": "zhihu",
  "type": "zvideo",
  "id": "123456789",
  "filename": "zhihu_123456789.link.json",
  "message": "URL解析成功"
}

小红书笔记

{
  "success": true,
  "platform": "xiaohongshu",
  "type": "note",
  "id": "abc123",
  "filename": "xiaohongshu_abc123.link.json",
  "message": "URL解析成功"
}

错误示例

不支持的平台

{
  "success": false,
  "error": "Unsupported URL format",
  "detail": "URL: https://example.com/video/123"
}

无效 URL

{
  "success": false,
  "error": "解析失败",
  "detail": "URL: not-a-valid-url"
}

支持的平台和类型

平台 类型 URL 示例
bilibili video bilibili.com/video/BVxxx
bilibili article bilibili.com/read/cvxxx
bilibili up主 space.bilibili.com/12345
bilibili favlist space.bilibili.com/123/favlist?fid=xxx
zhihu question zhihu.com/question/123
zhihu answer zhihu.com/question/123/answer/456
zhihu zhuanlan zhuanlan.zhihu.com/p/123
zhihu zvideo zhihu.com/zvideo/123
xiaohongshu note xiaohongshu.com/explore/xxx
youtube video youtube.com/watch?v=xxx

安装

cp -r kb-link-parser/ ~/.openclaw/skills/
pip install requests

在 kb-workflow 中的使用

# 步骤 1:链接解析
python3 ~/.openclaw/skills/kb-link-parser/link-parser.py --url "[用户提供的URL]"

# 解析输出后:
# - 检查 success 字段
# - 提取 platform, type, id
# - 生成 pending/{platform}_{id}.link.json
# - 进入步骤 2(元数据提取)