[ { "id": "TC-001", "type": "positive", "input": { "method": "YouTube Data API v3", "params": { "part": "snippet,statistics", "chart": "mostPopular", "maxResults": 10, "regionCode": "US" } }, "expected": { "videos": [{ "videoId": "string", "title": "string", "viewCount": "number", "channelTitle": "string", "thumbnail": "string", "publishedAt": "ISO8601" }] }, "dimensions": { "功能完整性": 95, "API规范使用": 92, "代码质量": 90, "数据准确性": 95, "反爬虫处理": 85, "降级方案支持": 90, "配置灵活性": 95, "性能优化": 85 }, "total_score": 91, "note": "完整 API 实现,含所有核心字段和配置选项" }, { "id": "TC-002", "type": "positive", "input": { "method": "yt-dlp", "url": "https://www.youtube.com/feed/trending", "limit": 20 }, "expected": { "videos": [{ "videoId": "string", "title": "string", "viewCount": "number", "channelTitle": "string" }] }, "dimensions": { "功能完整性": 88, "API规范使用": 0, "代码质量": 85, "数据准确性": 90, "反爬虫处理": 80, "降级方案支持": 95, "配置灵活性": 80, "性能优化": 75 }, "total_score": 82, "note": "yt-dlp 方案作为 API 降级备选" }, { "id": "TC-003", "type": "positive", "input": { "method": "API", "category": "music", "region": "JP", "maxResults": 50 }, "expected": { "videos": [{ "videoId": "string", "title": "string", "viewCount": "number", "channelTitle": "string", "category": "Music" }] }, "dimensions": { "功能完整性": 92, "API规范使用": 95, "代码质量": 88, "数据准确性": 92, "反爬虫处理": 85, "降级方案支持": 75, "配置灵活性": 95, "性能优化": 80 }, "total_score": 88, "note": "支持分类和地区参数配置" }, { "id": "TC-004", "type": "positive", "input": { "method": "API+yt-dlp", "auto_fallback": true, "retry": 3 }, "expected": { "videos": [{ "videoId": "string", "title": "string", "viewCount": "number" }], "source": "api|ytdlp" }, "dimensions": { "功能完整性": 90, "API规范使用": 88, "代码质量": 92, "数据准确性": 90, "反爬虫处理": 95, "降级方案支持": 95, "配置灵活性": 85, "性能优化": 88 }, "total_score": 91, "note": "双方案自动故障切换" }, { "id": "TC-005", "type": "positive", "input": { "method": "API", "cache": true, "cache_ttl": 900 }, "expected": { "videos": [{ "videoId": "string", "title": "string" }], "cached": true }, "dimensions": { "功能完整性": 88, "API规范使用": 90, "代码质量": 90, "数据准确性": 88, "反爬虫处理": 85, "降级方案支持": 70, "配置灵活性": 85, "性能优化": 95 }, "total_score": 87, "note": "实现 15 分钟缓存优化性能" }, { "id": "TC-006", "type": "positive", "input": { "method": "API", "maxResults": 1, "regionCode": "KR" }, "expected": { "videos_count": 1, "videos": [{ "videoId": "string", "title": "string" }] }, "dimensions": { "功能完整性": 90, "API规范使用": 92, "代码质量": 88, "数据准确性": 90, "反爬虫处理": 80, "降级方案支持": 70, "配置灵活性": 90, "性能优化": 80 }, "total_score": 85, "note": "边界测试:最小结果集 + 地区参数" }, { "id": "TC-007", "type": "positive", "input": { "method": "yt-dlp", "category": "gaming", "extract_flat": true }, "expected": { "videos": [{ "videoId": "string", "title": "string", "uploader": "string", "view_count": "number" }] }, "dimensions": { "功能完整性": 85, "API规范使用": 0, "代码质量": 85, "数据准确性": 88, "反爬虫处理": 85, "降级方案支持": 92, "配置灵活性": 85, "性能优化": 80 }, "total_score": 81, "note": "yt-dlp Gaming 分类 trending" }, { "id": "TC-008", "type": "positive", "input": { "method": "API", "part": "snippet,statistics,contentDetails" }, "expected": { "videos": [{ "videoId": "string", "title": "string", "duration": "ISO8601", "likeCount": "number" }] }, "dimensions": { "功能完整性": 98, "API规范使用": 95, "代码质量": 88, "数据准确性": 95, "反爬虫处理": 80, "降级方案支持": 70, "配置灵活性": 85, "性能优化": 80 }, "total_score": 89, "note": "扩展字段:duration 和 likeCount" }, { "id": "TC-009", "type": "positive", "input": { "method": "API", "error_handling": "try-catch", "retry_strategy": "exponential_backoff" }, "expected": { "videos": [{ "videoId": "string" }], "retry_count": "number" }, "dimensions": { "功能完整性": 88, "API规范使用": 88, "代码质量": 95, "数据准确性": 88, "反爬虫处理": 95, "降级方案支持": 80, "配置灵活性": 80, "性能优化": 85 }, "total_score": 88, "note": "完善的错误处理和重试策略" }, { "id": "TC-010", "type": "positive", "input": { "method": "API", "env_api_key": true, "validate_input": true }, "expected": { "videos": [{ "videoId": "string", "title": "string" }] }, "dimensions": { "功能完整性": 88, "API规范使用": 90, "代码质量": 92, "数据准确性": 88, "反爬虫处理": 85, "降级方案支持": 70, "配置灵活性": 95, "性能优化": 80 }, "total_score": 87, "note": "从环境变量读取 API Key,参数验证" }, { "id": "TC-011", "type": "positive", "input": { "method": "API", "quota_monitoring": true }, "expected": { "videos": [{ "videoId": "string" }], "quota_used": "number", "quota_remaining": "number" }, "dimensions": { "功能完整性": 88, "API规范使用": 95, "代码质量": 90, "数据准确性": 88, "反爬虫处理": 85, "降级方案支持": 75, "配置灵活性": 85, "性能优化": 92 }, "total_score": 89, "note": "配额监控和使用追踪" }, { "id": "TC-012", "type": "positive", "input": { "method": "yt-dlp", "request_delay": 2, "user_agent_rotation": true }, "expected": { "videos": [{ "videoId": "string", "title": "string" }] }, "dimensions": { "功能完整性": 85, "API规范使用": 0, "代码质量": 88, "数据准确性": 88, "反爬虫处理": 92, "降级方案支持": 90, "配置灵活性": 85, "性能优化": 80 }, "total_score": 84, "note": "yt-dlp 反爬虫优化:延迟和 UA 轮换" }, { "id": "TC-013", "type": "positive", "input": { "method": "API", "field_mapping": { "id": "videoId", "snippet.title": "title", "statistics.viewCount": "viewCount" } }, "expected": { "videos": [{ "videoId": "string", "title": "string", "viewCount": 1234567 }] }, "dimensions": { "功能完整性": 92, "API规范使用": 90, "代码质量": 90, "数据准确性": 95, "反爬虫处理": 80, "降级方案支持": 70, "配置灵活性": 88, "性能优化": 80 }, "total_score": 88, "note": "正确的字段映射和类型转换" }, { "id": "TC-014", "type": "positive", "input": { "method": "API", "thumbnails": ["default", "medium", "high", "maxres"] }, "expected": { "videos": [{ "thumbnails": { "default": "url", "medium": "url", "high": "url" } }] }, "dimensions": { "功能完整性": 95, "API规范使用": 92, "代码质量": 88, "数据准确性": 92, "反爬虫处理": 80, "降级方案支持": 70, "配置灵活性": 85, "性能优化": 80 }, "total_score": 88, "note": "多分辨率缩略图支持" }, { "id": "TC-015", "type": "positive", "input": { "method": "API+yt-dlp", "health_check": true }, "expected": { "api_status": "ok|error", "ytdlp_status": "ok|error", "recommended_method": "api|ytdlp" }, "dimensions": { "功能完整性": 88, "API规范使用": 88, "代码质量": 92, "数据准确性": 85, "反爬虫处理": 85, "降级方案支持": 95, "配置灵活性": 85, "性能优化": 80 }, "total_score": 87, "note": "健康检查和自动方案推荐" }, { "id": "TC-016", "type": "positive", "input": { "method": "API", "publishedAt_format": "ISO8601", "timezone": "UTC" }, "expected": { "videos": [{ "publishedAt": "2024-01-15T10:00:00Z" }] }, "dimensions": { "功能完整性": 90, "API规范使用": 92, "代码质量": 88, "数据准确性": 95, "反爬虫处理": 80, "降级方案支持": 70, "配置灵活性": 88, "性能优化": 80 }, "total_score": 87, "note": "时间格式标准化处理" }, { "id": "TC-017", "type": "positive", "input": { "method": "yt-dlp", "category_url": "https://www.youtube.com/feed/trending?bp=4gINGgt5dG1hX2NoYXJ0cw%3D%3D" }, "expected": { "videos": [{ "videoId": "string", "title": "string", "category": "Music" }] }, "dimensions": { "功能完整性": 85, "API规范使用": 0, "代码质量": 85, "数据准确性": 88, "反爬虫处理": 85, "降级方案支持": 92, "配置灵活性": 85, "性能优化": 80 }, "total_score": 81, "note": "yt-dlp Music 分类 trending URL" }, { "id": "TC-018", "type": "positive", "input": { "method": "API", "viewCount_parseInt": true }, "expected": { "videos": [{ "viewCount": 1234567 }] }, "dimensions": { "功能完整性": 90, "API规范使用": 90, "代码质量": 90, "数据准确性": 95, "反爬虫处理": 80, "降级方案支持": 70, "配置灵活性": 80, "性能优化": 80 }, "total_score": 86, "note": "viewCount 从字符串正确转为整数" }, { "id": "TC-019", "type": "positive", "input": { "method": "API", "rate_limit_handling": { "429": "retry_after_header", "403": "switch_to_ytdlp" } }, "expected": { "videos": [{ "videoId": "string" }], "source": "api|ytdlp", "retry_after": "number" }, "dimensions": { "功能完整性": 88, "API规范使用": 92, "代码质量": 92, "数据准确性": 88, "反爬虫处理": 95, "降级方案支持": 92, "配置灵活性": 85, "性能优化": 85 }, "total_score": 90, "note": "智能错误码处理和降级" }, { "id": "TC-020", "type": "positive", "input": { "method": "API", "batch_requests": false, "single_call": true }, "expected": { "videos_count": 50, "videos": [{ "videoId": "string" }] }, "dimensions": { "功能完整性": 92, "API规范使用": 95, "代码质量": 88, "数据准确性": 90, "反爬虫处理": 85, "降级方案支持": 70, "配置灵活性": 80, "性能优化": 88 }, "total_score": 87, "note": "单次调用最大化配额效率" }, { "id": "TC-021", "type": "negative", "input": { "method": "API", "part": "snippet" }, "expected": { "videos": [{ "videoId": "string", "title": "string", "viewCount": null }] }, "dimensions": { "功能完整性": 60, "API规范使用": 70, "代码质量": 70, "数据准确性": 50, "反爬虫处理": 60, "降级方案支持": 40, "配置灵活性": 60, "性能优化": 50 }, "total_score": 58, "note": "错误:part 参数缺少 statistics,无法获取 viewCount" }, { "id": "TC-022", "type": "negative", "input": { "method": "API", "hardcoded_api_key": "AIzaSyD..." }, "expected": { "error": "security_risk", "videos": [] }, "dimensions": { "功能完整性": 40, "API规范使用": 30, "代码质量": 40, "数据准确性": 50, "反爬虫处理": 40, "降级方案支持": 30, "配置灵活性": 30, "性能优化": 40 }, "total_score": 38, "note": "严重错误:API Key 硬编码在代码中" }, { "id": "TC-023", "type": "negative", "input": { "method": "API", "no_error_handling": true }, "expected": { "error": "unhandled_exception", "crash": true }, "dimensions": { "功能完整性": 50, "API规范使用": 50, "代码质量": 30, "数据准确性": 50, "反爬虫处理": 20, "降级方案支持": 30, "配置灵活性": 50, "性能优化": 40 }, "total_score": 39, "note": "严重错误:无 try-catch 错误处理" }, { "id": "TC-024", "type": "negative", "input": { "method": "API", "ignore_429": true, "rapid_requests": true }, "expected": { "error": "429", "retry": false, "blocked": true }, "dimensions": { "功能完整性": 60, "API规范使用": 50, "代码质量": 40, "数据准确性": 60, "反爬虫处理": 10, "降级方案支持": 30, "配置灵活性": 50, "性能优化": 30 }, "total_score": 41, "note": "严重错误:无视 429 错误,无重试机制" }, { "id": "TC-025", "type": "negative", "input": { "method": "API", "no_field_mapping": true, "raw_response": true }, "expected": { "videos": [{ "id": "string", "snippet": { "title": "string" }, "statistics": { "viewCount": "string" } }] }, "dimensions": { "功能完整性": 50, "API规范使用": 60, "代码质量": 40, "数据准确性": 40, "反爬虫处理": 50, "降级方案支持": 30, "配置灵活性": 50, "性能优化": 50 }, "total_score": 45, "note": "错误:未进行字段映射,返回原始 API 响应结构" }, { "id": "TC-026", "type": "negative", "input": { "method": "API", "part": "snippet,statistics", "chart": "mostPopular" }, "expected": { "videos": [{ "videoId": "string", "title": "string", "viewCount": "1000000" }] }, "dimensions": { "功能完整性": 70, "API规范使用": 70, "代码质量": 60, "数据准确性": 40, "反爬虫处理": 60, "降级方案支持": 40, "配置灵活性": 60, "性能优化": 60 }, "total_score": 58, "note": "错误:viewCount 未从字符串转为数字" }, { "id": "TC-027", "type": "negative", "input": { "method": "API", "hardcoded_params": true, "regionCode": "fixed_US" }, "expected": { "videos": [{ "videoId": "string" }], "region": "US" }, "dimensions": { "功能完整性": 70, "API规范使用": 60, "代码质量": 50, "数据准确性": 70, "反爬虫处理": 60, "降级方案支持": 40, "配置灵活性": 30, "性能优化": 60 }, "total_score": 54, "note": "错误:regionCode 等参数硬编码,不可配置" }, { "id": "TC-028", "type": "negative", "input": { "method": "API", "no_thumbnails": true }, "expected": { "videos": [{ "videoId": "string", "title": "string", "thumbnail": null }] }, "dimensions": { "功能完整性": 70, "API规范使用": 70, "代码质量": 60, "数据准确性": 70, "反爬虫处理": 60, "降级方案支持": 40, "配置灵活性": 60, "性能优化": 60 }, "total_score": 61, "note": "错误:未提取 thumbnails 字段" }, { "id": "TC-029", "type": "negative", "input": { "method": "yt-dlp", "no_user_agent": true, "rapid_fire": true }, "expected": { "error": "bot_detected", "blocked": true }, "dimensions": { "功能完整性": 50, "API规范使用": 0, "代码质量": 40, "数据准确性": 60, "反爬虫处理": 20, "降级方案支持": 60, "配置灵活性": 50, "性能优化": 40 }, "total_score": 41, "note": "错误:yt-dlp 无 User-Agent,请求过频被检测" }, { "id": "TC-030", "type": "negative", "input": { "method": "API", "search_instead_of_chart": true }, "expected": { "quota_cost": 100, "videos": [{ "videoId": "string" }] }, "dimensions": { "功能完整性": 80, "API规范使用": 40, "代码质量": 60, "数据准确性": 80, "反爬虫处理": 70, "降级方案支持": 40, "配置灵活性": 60, "性能优化": 30 }, "total_score": 55, "note": "错误:使用 search 端点(100 quota)代替 mostPopular(1 quota),浪费配额" }, { "id": "TC-031", "type": "negative", "input": { "method": "API", "no_cache": true, "repeated_calls": true }, "expected": { "api_calls": 10, "quota_wasted": 10, "videos": [{ "videoId": "string" }] }, "dimensions": { "功能完整性": 80, "API规范使用": 70, "代码质量": 60, "数据准确性": 80, "反爬虫处理": 70, "降级方案支持": 40, "配置灵活性": 60, "性能优化": 30 }, "total_score": 61, "note": "错误:无缓存机制,重复请求浪费配额" }, { "id": "TC-032", "type": "negative", "input": { "method": "API", "skip_validation": true, "invalid_region": "XX" }, "expected": { "error": "400_bad_request", "videos": [] }, "dimensions": { "功能完整性": 50, "API规范使用": 50, "代码质量": 40, "数据准确性": 50, "反爬虫处理": 50, "降级方案支持": 40, "配置灵活性": 50, "性能优化": 50 }, "total_score": 47, "note": "错误:未验证 regionCode 有效性,传入无效值" }, { "id": "TC-033", "type": "negative", "input": { "method": "API", "single_fallback": true, "api_fail": true }, "expected": { "error": "no_videos", "no_alternative": true }, "dimensions": { "功能完整性": 60, "API规范使用": 60, "代码质量": 50, "数据准确性": 60, "反爬虫处理": 50, "降级方案支持": 30, "配置灵活性": 50, "性能优化": 50 }, "total_score": 51, "note": "错误:API 失败时无降级方案" }, { "id": "TC-034", "type": "negative", "input": { "method": "page_scrape", "regex_brittle": "var ytInitialData = ({.*?});" }, "expected": { "error": "parse_failed", "html_changed": true }, "dimensions": { "功能完整性": 40, "API规范使用": 0, "代码质量": 40, "数据准确性": 40, "反爬虫处理": 30, "降级方案支持": 50, "配置灵活性": 50, "性能优化": 40 }, "total_score": 38, "note": "错误:页面解析方案脆弱,YouTube 页面结构变化即失效" }, { "id": "TC-035", "type": "negative", "input": { "method": "pytube", "get_trending": true }, "expected": { "error": "not_supported", "note": "pytube does not support trending directly" }, "dimensions": { "功能完整性": 20, "API规范使用": 0, "代码质量": 40, "数据准确性": 30, "反爬虫处理": 30, "降级方案支持": 20, "配置灵活性": 40, "性能优化": 30 }, "total_score": 28, "note": "严重错误:使用 pytube 直接获取 trending,该库不支持此功能" }, { "id": "TC-036", "type": "negative", "input": { "method": "API", "publishedAt_raw": true, "no_iso_format": true }, "expected": { "videos": [{ "publishedAt": "2024-01-15T10:00:00Z", "local_time": null }] }, "dimensions": { "功能完整性": 75, "API规范使用": 70, "代码质量": 60, "数据准确性": 60, "反爬虫处理": 60, "降级方案支持": 40, "配置灵活性": 60, "性能优化": 60 }, "total_score": 61, "note": "错误:未处理 publishedAt 时区和格式转换" }, { "id": "TC-037", "type": "negative", "input": { "method": "API", "maxResults": 100 }, "expected": { "error": "400", "valid_range": "1-50" }, "dimensions": { "功能完整性": 50, "API规范使用": 40, "代码质量": 50, "数据准确性": 50, "反爬虫处理": 50, "降级方案支持": 40, "配置灵活性": 50, "性能优化": 50 }, "total_score": 47, "note": "错误:maxResults 超出 API 限制(最大 50)" }, { "id": "TC-038", "type": "negative", "input": { "method": "API", "no_timeout": true, "network_hang": true }, "expected": { "error": "infinite_wait", "crash": true }, "dimensions": { "功能完整性": 50, "API规范使用": 50, "代码质量": 30, "数据准确性": 50, "反爬虫处理": 30, "降级方案支持": 40, "配置灵活性": 50, "性能优化": 40 }, "total_score": 42, "note": "错误:HTTP 请求无超时设置" }, { "id": "TC-039", "type": "negative", "input": { "method": "selenium", "headless_no_stealth": true }, "expected": { "error": "bot_detected", "captcha_triggered": true }, "dimensions": { "功能完整性": 50, "API规范使用": 0, "代码质量": 40, "数据准确性": 60, "反爬虫处理": 20, "降级方案支持": 50, "配置灵活性": 50, "性能优化": 30 }, "total_score": 40, "note": "错误:Selenium 无 stealth 模式,被 Bot 检测" }, { "id": "TC-040", "type": "negative", "input": { "method": "API", "url_concat_wrong": "https://youtube.com/v/{id}" }, "expected": { "videos": [{ "url": "https://youtube.com/v/xxx", "valid": false }] }, "dimensions": { "功能完整性": 75, "API规范使用": 70, "代码质量": 50, "数据准确性": 50, "反爬虫处理": 60, "降级方案支持": 40, "配置灵活性": 60, "性能优化": 60 }, "total_score": 58, "note": "错误:视频 URL 拼接错误(应为 /watch?v=)" } ]