08f7c9f26c
- Add extractors layer with BilibiliExtractor (Playwright stealth mode) - Add outputs layer with ObsidianWriter and GitSync - Implement subtitle/no-subtitle graceful degradation - Update config with output and bilibili extraction settings - Complete integration pipeline: extract → process → output → sync - Add comprehensive tests (100% pass rate) - Update documentation (SKILL.md, README.md, requirements.txt)
81 lines
1.9 KiB
Python
81 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
B站提取器测试脚本
|
|
"""
|
|
import sys
|
|
import os
|
|
|
|
# 添加父目录到路径
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from src.extractors.bilibili_extractor import BilibiliExtractor
|
|
from src.config import get_config
|
|
|
|
|
|
def main():
|
|
"""测试提取器"""
|
|
# 获取配置
|
|
config = get_config()
|
|
|
|
# 创建提取器
|
|
extractor = BilibiliExtractor(config=config)
|
|
|
|
# 测试BV号
|
|
bvid = "BV1MnFNz5EDL"
|
|
|
|
print(f"开始提取视频: {bvid}")
|
|
print("=" * 60)
|
|
|
|
try:
|
|
result = extractor.extract(bvid)
|
|
|
|
print("\n提取成功!\n")
|
|
print("=" * 60)
|
|
print("元数据 (metadata):")
|
|
print("=" * 60)
|
|
for key, value in result['metadata'].items():
|
|
print(f" {key}: {value}")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("统计数据 (stats):")
|
|
print("=" * 60)
|
|
for key, value in result['stats'].items():
|
|
print(f" {key}: {value:,}")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("简介 (description):")
|
|
print("=" * 60)
|
|
desc = result['description']
|
|
if len(desc) > 500:
|
|
print(desc[:500] + "...")
|
|
else:
|
|
print(desc)
|
|
|
|
print("\n" + "=" * 60)
|
|
print("字幕 (subtitle):")
|
|
print("=" * 60)
|
|
subtitle = result['subtitle']
|
|
if subtitle:
|
|
lines = subtitle.split('\n')
|
|
if len(lines) > 10:
|
|
print("\n".join(lines[:10]))
|
|
print(f"\n...(共 {len(lines)} 条字幕)")
|
|
else:
|
|
print(subtitle)
|
|
else:
|
|
print(" (无字幕)")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("✅ 测试完成")
|
|
print("=" * 60)
|
|
|
|
except Exception as e:
|
|
print(f"\n❌ 测试失败: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|