Merge pull request 'fix(bilibili): correct metadata and filename in archive' (#14) from fix/ci-deploy-reset into main
Deploy kb-skills / deploy (push) Successful in 2s

Reviewed-on: http://192.168.1.22:8418/starmen1265/kb-skills/pulls/14
This commit was merged in pull request #14.
This commit is contained in:
2026-03-16 13:49:42 +08:00
2 changed files with 32 additions and 16 deletions
+6 -15
View File
@@ -461,26 +461,17 @@ class BilibiliAdapter(PlatformAdapter):
return "video"
def _sanitize_filename(self, title: str, bvid: str) -> str:
"""Sanitize title for use as filename.
"""Generate standardized filename for video download.
Args:
title: Video title
bvid: Video BV号 for fallback
title: Video title (unused, kept for API compatibility)
bvid: Video BV号
Returns:
Safe filename string
Standardized filename in format "bilibili_{bvid}"
"""
# Keep alphanumeric, spaces, and common Chinese-safe chars
safe_title = "".join(
c for c in title
if c.isalnum() or c in (' ', '-', '_', '丨', '|')
).strip()[:50]
# Use bvid if title is empty
if not safe_title:
safe_title = f"video_{bvid}"
return safe_title
# Use standardized naming convention: platform_bvid
return f"bilibili_{bvid}"
def _create_cookie_file(self, cookie: str) -> str:
"""Create Netscape format cookie file for yt-dlp.
+26 -1
View File
@@ -226,6 +226,28 @@ class AnalyzeProcessor(BaseProcessor):
base_url=base_url
)
def _normalize_metadata(self, metadata: Dict) -> Dict:
"""标准化元数据结构(扁平化嵌套结构)
Args:
metadata: 原始元数据字典,可能是嵌套结构
Returns:
扁平化的元数据字典
"""
if not metadata:
return {}
# 如果已经是扁平结构(顶层有 title)
if 'title' in metadata:
return metadata
# 处理嵌套结构 {metadata: {...}, stats: {...}}
if 'metadata' in metadata:
return metadata['metadata'].copy()
return metadata
def _write_analysis_report(
self,
output_path: Path,
@@ -243,8 +265,11 @@ class AnalyzeProcessor(BaseProcessor):
"""
from kb_deep_analyzer.deep_analyzer import generate_frontmatter
# 标准化元数据(扁平化嵌套结构)
normalized_metadata = self._normalize_metadata(metadata)
# 生成 frontmatter
frontmatter = generate_frontmatter(metadata, result, content_type)
frontmatter = generate_frontmatter(normalized_metadata, result, content_type)
# 获取完整分析内容
full_analysis = result.full_analysis