自动同步: 2026-03-14 02:10
This commit is contained in:
+169
-22
@@ -1,43 +1,190 @@
|
||||
---
|
||||
name: kb-link-parser
|
||||
description: 链接解析器 - 从各平台 URL 提取平台类型、内容类型和 ID
|
||||
---
|
||||
|
||||
# KB Link Parser Skill
|
||||
|
||||
**kb-link-parser** - Extract and resolve IDs from various platform URLs.
|
||||
**kb-link-parser** - 从各种平台 URL 中提取和解析 ID。
|
||||
|
||||
## Features
|
||||
## 什么时候使用
|
||||
|
||||
- Multi-platform support: Bilibili, YouTube, Zhihu
|
||||
- Short link detection: b23.tv and other short links
|
||||
- Multiple content types: video, article, up主, playlist, collection
|
||||
- Batch processing from file
|
||||
- JSON output format
|
||||
- kb-workflow 步骤 1:解析用户提供的链接
|
||||
- 需要判断链接属于哪个平台、什么类型的内容
|
||||
|
||||
## Commands
|
||||
## 功能
|
||||
|
||||
- 多平台支持:Bilibili、YouTube、知乎、小红书
|
||||
- 短链接解析:b23.tv、xhslink.com 等
|
||||
- 多种内容类型:video、article、question、answer 等
|
||||
- 批量处理支持
|
||||
- JSON 输出格式
|
||||
|
||||
## 命令
|
||||
|
||||
```bash
|
||||
# Parse single URL
|
||||
python link-parser.py --url "https://www.bilibili.com/video/BV1xx411c7mD"
|
||||
# 解析单个 URL
|
||||
python3 link-parser.py --url "https://www.bilibili.com/video/BV1xx411c7mD"
|
||||
|
||||
# Batch processing
|
||||
python link-parser.py --batch urls.txt --output results.json
|
||||
# 批量处理
|
||||
python3 link-parser.py --batch urls.txt --output results.json
|
||||
|
||||
# Output format
|
||||
python link-parser.py --url "..." --format json
|
||||
# 指定输出格式
|
||||
python3 link-parser.py --url "..." --format json
|
||||
```
|
||||
|
||||
## Output
|
||||
## 输出格式 Schema
|
||||
|
||||
### 必需字段
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| `success` | boolean | 是否解析成功 |
|
||||
| `platform` | string | 平台名称(成功时必需) |
|
||||
| `type` | string | 内容类型(成功时必需) |
|
||||
| `id` | string | 内容 ID(成功时必需) |
|
||||
| `error` | string | 错误信息(失败时必需) |
|
||||
|
||||
### 可选字段
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| `filename` | string | 建议的文件名 |
|
||||
| `message` | string | 描述信息 |
|
||||
|
||||
## 成功示例
|
||||
|
||||
### B站视频
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"platform": "bilibili",
|
||||
"type": "video",
|
||||
"id": "BV1xx411c7mD"
|
||||
}
|
||||
"platform": "bilibili",
|
||||
"type": "video",
|
||||
"id": "BV1xx411c7mD",
|
||||
"filename": "bilibili_BV1xx411c7mD.link.json",
|
||||
"message": "URL解析成功"
|
||||
}
|
||||
```
|
||||
|
||||
## Installation
|
||||
### B站专栏
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"platform": "bilibili",
|
||||
"type": "article",
|
||||
"id": "cv43780186",
|
||||
"filename": "bilibili_cv43780186.link.json",
|
||||
"message": "URL解析成功"
|
||||
}
|
||||
```
|
||||
|
||||
### 知乎问答
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"platform": "zhihu",
|
||||
"type": "question",
|
||||
"id": "266309957",
|
||||
"filename": "zhihu_266309957.link.json",
|
||||
"message": "URL解析成功"
|
||||
}
|
||||
```
|
||||
|
||||
### 知乎专栏文章
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"platform": "zhihu",
|
||||
"type": "zhuanlan",
|
||||
"id": "1894054073625461813",
|
||||
"filename": "zhihu_1894054073625461813.link.json",
|
||||
"message": "URL解析成功"
|
||||
}
|
||||
```
|
||||
|
||||
### 知乎视频
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"platform": "zhihu",
|
||||
"type": "zvideo",
|
||||
"id": "123456789",
|
||||
"filename": "zhihu_123456789.link.json",
|
||||
"message": "URL解析成功"
|
||||
}
|
||||
```
|
||||
|
||||
### 小红书笔记
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"platform": "xiaohongshu",
|
||||
"type": "note",
|
||||
"id": "abc123",
|
||||
"filename": "xiaohongshu_abc123.link.json",
|
||||
"message": "URL解析成功"
|
||||
}
|
||||
```
|
||||
|
||||
## 错误示例
|
||||
|
||||
### 不支持的平台
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"error": "Unsupported URL format",
|
||||
"detail": "URL: https://example.com/video/123"
|
||||
}
|
||||
```
|
||||
|
||||
### 无效 URL
|
||||
|
||||
```json
|
||||
{
|
||||
"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` |
|
||||
|
||||
## 安装
|
||||
|
||||
```bash
|
||||
cp -r kb-link-parser/ ~/skills/
|
||||
cp -r kb-link-parser/ ~/.openclaw/skills/
|
||||
pip install requests
|
||||
```
|
||||
|
||||
## 在 kb-workflow 中的使用
|
||||
|
||||
```bash
|
||||
# 步骤 1:链接解析
|
||||
python3 ~/.openclaw/skills/kb-link-parser/link-parser.py --url "[用户提供的URL]"
|
||||
|
||||
# 解析输出后:
|
||||
# - 检查 success 字段
|
||||
# - 提取 platform, type, id
|
||||
# - 生成 pending/{platform}_{id}.link.json
|
||||
# - 进入步骤 2(元数据提取)
|
||||
```
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user