YouTube 频道中的“已发布视频”和“上传”有啥区别?以及如何通过 YouTube Data v3 API 获取它们?

Posted

技术标签:

【中文标题】YouTube 频道中的“已发布视频”和“上传”有啥区别?以及如何通过 YouTube Data v3 API 获取它们?【英文标题】:What is difference of "Posted video" and "Uploads" in YouTube Channel? And how to get them through YouTube Data v3 API?YouTube 频道中的“已发布视频”和“上传”有什么区别?以及如何通过 YouTube Data v3 API 获取它们? 【发布时间】:2014-10-30 04:43:29 【问题描述】:

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

    Go Pro Channel: https://www.youtube.com/user/GoProCamera/videos YouTube curated Sports Channel: https://www.youtube.com/channel/UCEgdi0XIXXZ-qJOFPf4JSKw/videos

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

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

对于Go Pro Channel,我至少可以依靠这里提到的方法来获取上传的视频:How do I get a list of uploaded videos for a certain channel with the new 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": [
 ]

在我看来,现在这是一条死胡同,那么有没有办法从这种精选频道获取视频?

【问题讨论】:

【参考方案1】:

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

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

【讨论】:

谢谢,您的示例 API 调用确实输出了一些结果,但目前它们与官方频道内容完全不同(youtube.com/channel/UCEgdi0XIXXZ-qJOFPf4JSKw/…) 对此行为有什么想法吗? 更新,在使用提供的 API 调用仔细阅读搜索结果后,它只是将这个频道下的所有播放列表项转储给我,而不是我想要的视频。如果我强制它列出视频条目,它又给了我空的结果。

以上是关于YouTube 频道中的“已发布视频”和“上传”有啥区别?以及如何通过 YouTube Data v3 API 获取它们?的主要内容,如果未能解决你的问题,请参考以下文章

如何上传到同一帐户的特定 YouTube 频道? (YouTube 数据 API)

在youtube频道上传的最新视频

如何使用 PHP 在另一个 youtube 频道上上传一个 youtube 视频

使用 Youtube Api v3 和 oauth2 将视频上传到我的 Youtube 频道,无需用户身份验证

使用 YouTube Data API v3 确定 YouTube 频道的上传速率

如何获取上传到多个 YouTube 频道的最新视频列表?