train_dataset.json 10.3 KB
{
  "skill": "youtube-data-expert",
  "version": "1.0.0",
  "total_samples": 40,
  "samples": [
    {
      "id": "train-001",
      "type": "api_call",
      "task": "批量获取视频详情",
      "input": {
        "videoIds": ["dQw4w9WgXcQ", "9bZkp7q19f0", "kJQP7kiw5Fk"],
        "part": "snippet,statistics,contentDetails"
      },
      "expected_api": "GET /videos?id=dQw4w9WgXcQ,9bZkp7q19f0,kJQP7kiw5Fk&part=snippet,statistics,contentDetails&key={API_KEY}",
      "expected_quota": 1,
      "expected_output_fields": ["id", "snippet.title", "snippet.channelId", "statistics.viewCount", "contentDetails.duration"]
    },
    {
      "id": "train-002",
      "type": "api_call",
      "task": "批量获取频道详情",
      "input": {
        "channelIds": ["UC_x5XG1OV2P6uZZ5FSM9Ttw", "UCBR8-60-B28hp2BmDPdntcQ"]
      },
      "expected_api": "GET /channels?id=UC_x5XG1OV2P6uZZ5FSM9Ttw,UCBR8-60-B28hp2BmDPdntcQ&part=snippet,statistics",
      "expected_quota": 1
    },
    {
      "id": "train-003",
      "type": "search",
      "task": "搜索视频",
      "input": {
        "q": "machine learning tutorial",
        "type": "video",
        "maxResults": 25,
        "order": "relevance"
      },
      "expected_api": "GET /search?q=machine+learning+tutorial&type=video&maxResults=25&order=relevance",
      "expected_quota": 100
    },
    {
      "id": "train-004",
      "type": "api_call",
      "task": "获取频道上传列表",
      "input": {
        "uploadsPlaylistId": "UUPxMZIFE215t3YupO8B1Bdw",
        "maxResults": 50
      },
      "expected_api": "GET /playlistItems?playlistId=UUPxMZIFE215t3YupO8B1Bdw&maxResults=50&part=snippet",
      "expected_quota": 1
    },
    {
      "id": "train-005",
      "type": "pagination",
      "task": "分页获取",
      "input": {
        "endpoint": "/search",
        "params": {"q": "python", "type": "video"},
        "pageToken": "CAEQAA"
      },
      "expected_api": "GET /search?q=python&type=video&pageToken=CAEQAA",
      "expected_behavior": "使用 pageToken 获取下一页,累加配额"
    },
    {
      "id": "train-006",
      "type": "error_handling",
      "task": "处理 403 配额耗尽错误",
      "input": {"error": {"code": 403, "errors": [{"reason": "quotaExceeded"}]}},
      "expected_behavior": "立即停止执行,抛出错误 'API quota exceeded (10000/10000 units)'"
    },
    {
      "id": "train-007",
      "type": "error_handling",
      "task": "处理 429 速率限制",
      "input": {"error": {"code": 429}},
      "expected_behavior": "指数退避重试: 等待 1s → 2s → 4s → 8s,最多3次"
    },
    {
      "id": "train-008",
      "type": "error_handling",
      "task": "处理 404 资源不存在",
      "input": {"videoId": "invalid_id_12345"},
      "expected_behavior": "跳过该资源,记录警告日志,继续处理其他资源"
    },
    {
      "id": "train-009",
      "type": "data_parsing",
      "task": "解析 ISO 8601 时长",
      "input": {"duration": "PT15M33S"},
      "expected_output": 933
    },
    {
      "id": "train-010",
      "type": "data_parsing",
      "task": "解析 ISO 8601 时长 (小时)",
      "input": {"duration": "PT1H30M15S"},
      "expected_output": 5415
    },
    {
      "id": "train-011",
      "type": "data_parsing",
      "task": "解析 ISO 8601 时长 (秒)",
      "input": {"duration": "PT30S"},
      "expected_output": 30
    },
    {
      "id": "train-012",
      "type": "boundary",
      "task": "处理 videoCount=0",
      "input": {"viewCount": 1000, "videoCount": 0},
      "expected_behavior": "views_per_video = 0 (避免除以零)"
    },
    {
      "id": "train-013",
      "type": "boundary",
      "task": "处理隐藏订阅数",
      "input": {"hiddenSubscriberCount": true, "viewCount": 1000000, "videoCount": 100},
      "expected_behavior": "estimated_subs = viewCount / videoCount * 10 = 100000"
    },
    {
      "id": "train-014",
      "type": "quota_tracking",
      "task": "计算配额使用",
      "input": {
        "requests": [
          {"endpoint": "search", "count": 2},
          {"endpoint": "videos", "count": 5},
          {"endpoint": "channels", "count": 3}
        ]
      },
      "expected_quota": 208
    },
    {
      "id": "train-015",
      "type": "quota_tracking",
      "task": "配额警告检查",
      "input": {"quota_used": 8200, "quota_limit": 10000},
      "expected_behavior": "发出警告: 'Quota usage 8200/10000, approaching limit'"
    },
    {
      "id": "train-016",
      "type": "data_validation",
      "task": "验证视频ID格式",
      "input": {"videoId": "dQw4w9WgXcQ"},
      "expected_behavior": "返回 true (11字符,有效字符)"
    },
    {
      "id": "train-017",
      "type": "data_validation",
      "task": "验证视频ID格式 (无效)",
      "input": {"videoId": "invalid"},
      "expected_behavior": "返回 false"
    },
    {
      "id": "train-018",
      "type": "data_validation",
      "task": "验证频道ID格式",
      "input": {"channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw"},
      "expected_behavior": "返回 true (UC开头,有效字符)"
    },
    {
      "id": "train-019",
      "type": "output_format",
      "task": "生成 JSON 输出",
      "input": {"videos": [{"id": "abc", "title": "Test"}]},
      "expected_output_structure": {
        "metadata": {"exported_at": "ISO8601", "total_items": 1, "quota_used": 1},
        "data": [{"id": "abc", "title": "Test"}]
      }
    },
    {
      "id": "train-020",
      "type": "search",
      "task": "搜索频道",
      "input": {"q": "MKBHD", "type": "channel", "maxResults": 5},
      "expected_quota": 100
    },
    {
      "id": "train-021",
      "type": "api_call",
      "task": "获取视频评论",
      "input": {"videoId": "dQw4w9WgXcQ", "maxResults": 20},
      "expected_api": "GET /commentThreads?videoId=dQw4w9WgXcQ&maxResults=20&part=snippet",
      "expected_quota": 1
    },
    {
      "id": "train-022",
      "type": "batch_optimization",
      "task": "分割大批量请求",
      "input": {"videoIds": ["...75个ID..."]},
      "expected_behavior": "分成 2 批: 50个 + 25个,共 2 units"
    },
    {
      "id": "train-023",
      "type": "data_parsing",
      "task": "解析发布时间为 Date 对象",
      "input": {"publishedAt": "2024-03-15T10:30:00Z"},
      "expected_output": "Date object or timestamp"
    },
    {
      "id": "train-024",
      "type": "data_parsing",
      "task": "解析大数字",
      "input": {"viewCount": "1234567890"},
      "expected_output": 1234567890
    },
    {
      "id": "train-025",
      "type": "error_handling",
      "task": "处理网络超时",
      "input": {"error": {"code": "ETIMEDOUT"}},
      "expected_behavior": "重试3次,间隔指数退避,最后报告超时错误"
    },
    {
      "id": "train-026",
      "type": "boundary",
      "task": "处理缺失的 statistics",
      "input": {"id": "abc", "snippet": {"title": "Test"}},
      "expected_behavior": "返回默认值: viewCount=0, likeCount=0, commentCount=0"
    },
    {
      "id": "train-027",
      "type": "api_call",
      "task": "获取视频分类列表",
      "input": {"regionCode": "US"},
      "expected_api": "GET /videoCategories?regionCode=US&part=snippet",
      "expected_quota": 1
    },
    {
      "id": "train-028",
      "type": "search",
      "task": "带日期范围的搜索",
      "input": {"q": "python", "publishedAfter": "2024-01-01T00:00:00Z", "publishedBefore": "2024-03-01T00:00:00Z"},
      "expected_quota": 100
    },
    {
      "id": "train-029",
      "type": "data_parsing",
      "task": "提取缩略图 URL",
      "input": {"thumbnails": {"default": {"url": "..."}, "high": {"url": "..."}}},
      "expected_behavior": "返回最佳可用质量缩略图 URL"
    },
    {
      "id": "train-030",
      "type": "output_format",
      "task": "生成 CSV 输出",
      "input": {"videos": [{"id": "abc", "title": "Test, with comma", "viewCount": 1000}]},
      "expected_behavior": "正确处理逗号和引号,生成有效 CSV"
    },
    {
      "id": "train-031",
      "type": "api_call",
      "task": "获取相关视频",
      "input": {"relatedToVideoId": "dQw4w9WgXcQ", "type": "video"},
      "expected_api": "GET /search?relatedToVideoId=dQw4w9WgXcQ&type=video",
      "expected_quota": 100
    },
    {
      "id": "train-032",
      "type": "quota_tracking",
      "task": "配额重置时间",
      "input": {},
      "expected_behavior": "报告 'Quota resets at midnight Pacific Time'"
    },
    {
      "id": "train-033",
      "type": "error_handling",
      "task": "处理 400 无效参数",
      "input": {"error": {"code": 400, "message": "Invalid parameter"}},
      "expected_behavior": "记录错误详情,检查参数后重试一次"
    },
    {
      "id": "train-034",
      "type": "api_call",
      "task": "获取播放列表详情",
      "input": {"playlistId": "PLxxx", "part": "snippet"},
      "expected_api": "GET /playlists?id=PLxxx&part=snippet",
      "expected_quota": 1
    },
    {
      "id": "train-035",
      "type": "data_validation",
      "task": "验证日期格式",
      "input": {"date": "2024-03-15T10:30:00Z"},
      "expected_behavior": "返回 true (有效 ISO 8601)"
    },
    {
      "id": "train-036",
      "type": "data_parsing",
      "task": "计算视频年龄",
      "input": {"publishedAt": "2020-01-01T00:00:00Z"},
      "expected_behavior": "返回天数差: ~1500天"
    },
    {
      "id": "train-037",
      "type": "search",
      "task": "频道内搜索",
      "input": {"channelId": "UCxxx", "q": "tutorial"},
      "expected_api": "GET /search?channelId=UCxxx&q=tutorial&type=video",
      "expected_quota": 100
    },
    {
      "id": "train-038",
      "type": "boundary",
      "task": "处理超长描述",
      "input": {"description": "a".repeat(5000)},
      "expected_behavior": "保留完整内容或截断到合理长度"
    },
    {
      "id": "train-039",
      "type": "error_handling",
      "task": "处理 500 服务器错误",
      "input": {"error": {"code": 500}},
      "expected_behavior": "延迟3秒后重试一次,仍失败则报告错误"
    },
    {
      "id": "train-040",
      "type": "api_call",
      "task": "获取热门视频",
      "input": {"chart": "mostPopular", "regionCode": "US", "maxResults": 10},
      "expected_api": "GET /videos?chart=mostPopular&regionCode=US&maxResults=10",
      "expected_quota": 1
    }
  ]
}
</content>