YouTube 频道中的"Posted video"和"Uploads"有什么区别?以及如何通过YouTube Data v3 API获取它们?



我正在使用YouTube Data v3 API开发YouTube客户端,并正在使用观察到的两个不同频道播放:

  1. Go Pro频道:https://www.youtube.com/user/GoProCamera/videos
  2. YouTube策划的体育频道:https://www.youtube.com/channel/UCEgdi0XIXXZ-qJOFPf4JSKw/videos

在Go Pro频道中,我还可以选择一个视频过滤器:"上传"、"点赞"one_answers"发布的视频"。我对"上传"one_answers"发布的视频"过滤器感到非常困惑,根据我的观察,在这个频道上,它们给出了相同的结果。但在YouTube策划的体育频道中,只有"发布视频"选项。

在过去的几个小时里,我无法从YouTube v2/v3的API文档中找到任何明确的解释,更让我困扰的是,我找不到任何API来检索这些频道中的视频输入数据。

对于Go Pro频道,我至少可以依靠这里提到的方法来获得上传的视频:如何使用新的YouTube Data API(V3)获得某个频道的上传视频列表?

但对于精心策划的频道,即使这种方法也不起作用,频道查询结果中给出的播放列表总是空的:

Request

GET https://www.googleapis.com/youtube/v3/channels?part=id%2CcontentDetails%2Csnippet&id=UCEgdi0XIXXZ-qJOFPf4JSKw&key={YOUR_API_KEY}
Authorization:  Bearer ya29.dwCMU6xpf5N9AxwAAABgIM94lgv7jGHw0h0oEjs6uZUdPFO28CDYhbvgXdKTjw
X-JavaScript-User-Agent:  Google APIs Explorer

Response

200 OK
- Show headers -
{
 "kind": "youtube#channelListResponse",
 "etag": ""WFPuK6TsnblcGPcnMex79s42ynQ/qpdedwjxXQ-COrk0dODO-8DTAx0"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": ""WFPuK6TsnblcGPcnMex79s42ynQ/TP96YXZ0G4VPdQ7fd2IYgW79rW0"",
   "id": "UCEgdi0XIXXZ-qJOFPf4JSKw",
   "snippet": {
    "title": "Sports",
    "description": "Sport is all forms of usually competitive physical activity which, through casual or organised participation, aim to use, maintain or improve physical ability and skills while providing entertainment to participants, and in some cases, spectators. Hundreds of sports exist, from those requiring only two participants, through to those with hundreds of simultaneous participants, either in teams or competing as individuals. Sport is generally recognised as activities which are based in physical athleticism or physical dexterity, with the largest major competitions such as the Olympic Games admitting only sports meeting this definition, and other organisations such as the Council of Europe using definitions precluding activities without a physical element from classification as sports. However, a number of competitive, but non-physical, activities claim recognition as mind sports.nThis channel was generated automatically by YouTube's video discovery system.",
    "publishedAt": "2013-12-15T20:39:04.000Z",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/i/Egdi0XIXXZ-qJOFPf4JSKw/1.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/i/Egdi0XIXXZ-qJOFPf4JSKw/mq1.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/i/Egdi0XIXXZ-qJOFPf4JSKw/hq1.jpg"
     }
    }
   },
   "contentDetails": {
    "relatedPlaylists": {
     "likes": "LLEgdi0XIXXZ-qJOFPf4JSKw",
     "uploads": "UUEgdi0XIXXZ-qJOFPf4JSKw"
    }
   }
  }
 ]
}

--

Request

GET https://www.googleapis.com/youtube/v3/playlistItems?part=id%2CcontentDetails%2Csnippet&playlistId=UUEgdi0XIXXZ-qJOFPf4JSKw&key={YOUR_API_KEY}
X-JavaScript-User-Agent:  Google APIs Explorer

Response

200 OK
- Show headers -
{
 "kind": "youtube#playlistItemListResponse",
 "etag": ""WFPuK6TsnblcGPcnMex79s42ynQ/0ky7gu-r2KEON6-qkmzKhU77B-Q"",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 5
 },
 "items": [
 ]
}

在我看来,现在这是一条死胡同,那么有什么办法从这种策划的渠道获取视频吗?

如果你已经获得了策划频道的频道ID,你可以使用搜索端点来获取视频;例如,这个API调用将接收添加到YouTube体育频道的50个最新视频:

https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCEgdi0XIXXZ-qJOFPf4JSKw&maxResults=50&order=date&key={YOUR_API_KEY}

相关内容

  • 没有找到相关文章

最新更新