fix(kb-workflow): 修正路径管理和子技能逻辑
- kb_workflow.py: 修复目录查询命令(--pending, --metadata等) - bilibili_metadata.py: headless默认True,逻辑保持纯净 - deep_analyzer.py: 添加缺失的pathlib.Path导入 - SKILL.md: 更新步骤说明,明确由workflow提供路径给子技能 fix: 修复Playwright启动失败(NameError)和路径自动获取问题
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# 新加坡分区漫游指南
|
||||
|
||||
## 视频信息
|
||||
- **标题**:新加坡分区漫游指南:中心区打卡暴走丨圣淘沙度假丨动物园亲子,行程规划一目了然
|
||||
- **来源**:哔哩哔哩
|
||||
- **链接**:https://b23.tv/Tpa9SG7
|
||||
|
||||
## 内容概述
|
||||
新加坡旅游行程规划,分三个主要区域:
|
||||
|
||||
### 1. 中心区(City Walk打卡)
|
||||
- 滨海湾花园(花穹、云雾林)
|
||||
- 超级树灯光秀
|
||||
- 鱼尾狮公园
|
||||
- 滨海艺术中心
|
||||
- 克拉码头
|
||||
- 福康宁山
|
||||
|
||||
### 2. 圣淘沙度假
|
||||
- 环球影城
|
||||
- SEA海洋馆
|
||||
- 圣淘沙缆车(花柏山线进岛)
|
||||
- 沙滩 beaches
|
||||
|
||||
### 3. 动物园亲子游
|
||||
- 新加坡日间动物园
|
||||
- 河川生态园
|
||||
- 夜间野生动物园(Night Safari)
|
||||
- 飞禽公园
|
||||
|
||||
## 交通提示
|
||||
- 市区→圣淘沙:港湾站(Harbourfront)换乘
|
||||
- 动物园:地铁+公交前往
|
||||
|
||||
## 标签
|
||||
#新加坡 #旅游攻略 #圣淘沙 #动物园 #行程规划 #亲子游
|
||||
@@ -12,14 +12,14 @@
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
# Download video
|
||||
python bilibili_content.py --id "BV1xx411c7mD" --type video --quality 480
|
||||
# Download video (传入 --output 指定完整路径)
|
||||
python bilibili_content.py --id "BV1xx411c7mD" --type video --quality 480 --output "/path/to/downloads/BV1xx.mp4"
|
||||
|
||||
# Extract subtitle
|
||||
python bilibili_content.py --id "BV1xx411c7mD" --type subtitle
|
||||
# Extract subtitle (传入 --output 指定完整路径)
|
||||
python bilibili_content.py --id "BV1xx411c7mD" --type subtitle --output "/path/to/subtitles/BV1xx.srt"
|
||||
|
||||
# Get article content
|
||||
python bilibili_content.py --id "cv43780186" --type article
|
||||
# Get article content (传入 --output 指定完整路径)
|
||||
python bilibili_content.py --id "cv43780186" --type article --output "/path/to/article.md"
|
||||
```
|
||||
|
||||
## Output
|
||||
@@ -27,13 +27,10 @@ python bilibili_content.py --id "cv43780186" --type article
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"platform": "bilibili",
|
||||
"type": "video",
|
||||
"id": "BV1xx411c7mD",
|
||||
"video_file": {"path": "output/BV1xx.mp4", "quality": "480p"},
|
||||
"subtitle": {"path": "output/BV1xx.srt"}
|
||||
}
|
||||
"type": "video",
|
||||
"filename": "BV1xx.mp4",
|
||||
"filepath": "/path/to/downloads/BV1xx.mp4",
|
||||
"message": "下载完成"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ B站元数据提取 CLI 工具
|
||||
import argparse
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any
|
||||
|
||||
from bilibili_extractor import BilibiliExtractor
|
||||
@@ -145,8 +147,8 @@ def main():
|
||||
parser.add_argument(
|
||||
'--headless',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='使用无头模式(浏览器,默认关闭,使用API)'
|
||||
default=True,
|
||||
help='使用无头模式(浏览器,默认开启,使用API)'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--timeout',
|
||||
@@ -208,6 +210,11 @@ def main():
|
||||
|
||||
print(json.dumps(output, ensure_ascii=False, indent=2))
|
||||
|
||||
# 如果指定了输出路径,则写入文件
|
||||
if args.output:
|
||||
with open(args.output, 'w', encoding='utf-8') as f:
|
||||
json.dump(result, f, ensure_ascii=False, indent=2)
|
||||
|
||||
except Exception as e:
|
||||
print(json.dumps({
|
||||
"success": False,
|
||||
|
||||
@@ -16,6 +16,7 @@ import os
|
||||
import sys
|
||||
import re
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any, List, Optional, Tuple
|
||||
from dataclasses import dataclass, field, asdict
|
||||
|
||||
|
||||
@@ -67,21 +67,24 @@ python3 /path/to/link-parser.py --url "[URL]"
|
||||
|
||||
### 步骤 3: 元数据提取
|
||||
|
||||
1. 获取目录路径:
|
||||
1. 获取元数据目录路径:
|
||||
```bash
|
||||
python3 kb_workflow.py --metadata
|
||||
# 返回: {"path": "/home/admin/work/knowledge-base/metadata"}
|
||||
```
|
||||
|
||||
2. 启动子代理调用对应平台的 metadata 技能:
|
||||
2. 构建输出文件路径:`${metadata_dir}/${platform}_${id}.meta.json`
|
||||
|
||||
3. 启动子代理调用对应平台的 metadata 技能(传入 `--output`):
|
||||
```bash
|
||||
# Bilibili
|
||||
python3 /path/to/bilibili_metadata.py --id "[ID]" --type video
|
||||
python3 /path/to/bilibili_metadata.py --id "[ID]" --type video --output "${metadata_dir}/bilibili_[ID].meta.json"
|
||||
|
||||
# Zhihu
|
||||
python3 /path/to/zhihu_metadata.py --id "[ID]" --type question
|
||||
python3 /path/to/zhihu_metadata.py --id "[ID]" --type question --output "${metadata_dir}/zhihu_[ID].meta.json"
|
||||
```
|
||||
|
||||
3. 解析输出 JSON,提取 filename
|
||||
4. 解析输出 JSON,提取 filename
|
||||
|
||||
### 步骤 4: 内容下载
|
||||
|
||||
|
||||
@@ -258,6 +258,7 @@ def main():
|
||||
args = parser.parse_args()
|
||||
|
||||
base_path = Path(args.base_path) if args.base_path else None
|
||||
dirs = ensure_directories(base_path)
|
||||
|
||||
if args.check and args.url:
|
||||
result = check_duplicate(base_path, args.url)
|
||||
@@ -267,11 +268,36 @@ def main():
|
||||
result = archive_and_git(args.archive_file, base_path)
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
|
||||
elif args.pending:
|
||||
print(json.dumps({"path": str(dirs["pending"])}, ensure_ascii=False, indent=2))
|
||||
|
||||
elif args.metadata:
|
||||
print(json.dumps({"path": str(dirs["metadata"])}, ensure_ascii=False, indent=2))
|
||||
|
||||
elif args.content:
|
||||
print(json.dumps({"path": str(dirs["content"])}, ensure_ascii=False, indent=2))
|
||||
|
||||
elif args.content_downloads:
|
||||
print(json.dumps({"path": str(dirs["content_downloads"])}, ensure_ascii=False, indent=2))
|
||||
|
||||
elif args.content_subtitles:
|
||||
print(json.dumps({"path": str(dirs["content_subtitles"])}, ensure_ascii=False, indent=2))
|
||||
|
||||
elif args.analyzed:
|
||||
print(json.dumps({"path": str(dirs["analyzed"])}, ensure_ascii=False, indent=2))
|
||||
|
||||
elif args.archive_dir:
|
||||
path = dirs.get("archive")
|
||||
if path:
|
||||
print(json.dumps({"path": str(path)}, ensure_ascii=False, indent=2))
|
||||
return
|
||||
print(json.dumps({"path": str(dirs["archive"])}, ensure_ascii=False, indent=2))
|
||||
|
||||
elif args.archive_subscriptions:
|
||||
print(json.dumps({"path": str(dirs["archive_subscriptions"])}, ensure_ascii=False, indent=2))
|
||||
|
||||
elif args.extract_platform:
|
||||
platform = extract_platform(args.extract_platform)
|
||||
print(json.dumps({"platform": platform}, ensure_ascii=False, indent=2))
|
||||
|
||||
elif args.base_path:
|
||||
print(json.dumps({"path": str(dirs["base"])}, ensure_ascii=False, indent=2))
|
||||
|
||||
else:
|
||||
parser.print_help()
|
||||
|
||||
Reference in New Issue
Block a user