fix(kb-deep-analyzer): 优化文档格式

- date 改为视频发布日期(pubtime)
- 添加 url 到 frontmatter
- 去掉建议行动章节
- 去掉 {% if timeline %} 和最后分析时间
- 简化模板结构
This commit is contained in:
2026-02-13 14:57:07 +08:00
parent c8ddc1e83f
commit 518f8e4805
+17 -18
View File
@@ -1211,21 +1211,11 @@ class TemplateLoader:
- {{insight}}
{% endfor %}
## 建议行动
{% for action in actions %}
- [ ] {{action}}
{% endfor %}
{% if timeline %}
## 时间轴
{% for entry in timeline %}
### {{entry.index}}. {{entry.start_time}} - {{entry.end_time}}
{{entry.title}}: {{entry.summary}}
{% endfor %}
{% endif %}
---
*分析时间: {{analyze_time}}*
""",
"article": """# {{title}}
@@ -1242,11 +1232,6 @@ class TemplateLoader:
- {{insight}}
{% endfor %}
## 建议行动
{% for action in actions %}
- [ ] {{action}}
{% endfor %}
---
*分析时间: {{analyze_time}}*
"""
@@ -1506,17 +1491,31 @@ def result_to_dict(result: AnalysisResult) -> Dict:
def generate_frontmatter(metadata: Dict, result: AnalysisResult) -> str:
"""生成 Markdown frontmatter"""
tags = result.recommended_tags or result.main_topics[:5]
analyze_time = datetime.now().strftime('%Y-%m-%d %H:%M')
# 格式化视频发布日期(使用 pubtime)
pubtime = metadata.get('pubtime', '')
if pubtime:
if isinstance(pubtime, (int, float)):
from datetime import datetime
date_str = datetime.fromtimestamp(pubtime).strftime('%Y-%m-%d')
else:
date_str = str(pubtime)[:10]
else:
date_str = ""
fm = ["---",
f"title: \"{metadata.get('title', '未命名')}\"",
f"date: {datetime.now().strftime('%Y-%m-%d')}",
f"date: {date_str}",
f"duration: {format_duration(metadata.get('duration', 0))}",
f"author: {metadata.get('author', '未知')}",
f"analyze_time: {analyze_time}",
f"bvid: {metadata.get('bvid', '')}",
f"platform: {metadata.get('platform', 'bilibili')}"]
# 添加视频 URL
url = metadata.get('url', '')
if url:
fm.append(f"url: {url}")
if tags:
fm.append("tags: [" + ", ".join(f'"{t}"' for t in tags) + "]")