当前位置: 首页 > 知识库问答 >
问题:

YouTube频道中“发布视频”和“上传”的区别是什么?以及如何通过YouTube Data v3 API获取这些数据?

常光明
2023-03-14

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

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

在Go Pro频道中,我还可以选择视频过滤器:“上传”、“喜欢”和“发布视频”。我对“上传”和“发布视频”过滤器很困惑,据我观察,在这个频道上,它们给出的结果是一样的。但是在YouTube精选的体育频道中,只有“发布视频”选项。

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

对于Go Pro频道,我至少可以依靠这里提到的方法来获取上传的视频:如何使用新的YouTube数据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个答案

吕自明
2023-03-14

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

https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCEgdi0XIXXZ-qJOFPf4JSKw&maxResults=50&order=date&key={YOUR_API_KEY}
 类似资料:
  • https://www.googleapis.com/youtube/v3/search?part=snippet 但对于某些频道,它不获取视频,只获取播放列表。如果你转到Youtube频道并点击视频链接,它将显示所有频道的视频。在视频链接下会有一个发布的部分。示例: https://www.googleapis.com/youtube/v3/search?part=snippet 有人知道我怎么

  • 我正在尝试使用频道的视频,https://www.googleapis.com/youtube/v3/search?order=date

  • 我正在尝试通过YouTube数据API v3将视频上传到多个频道。 当我将视频上传到主默认频道时,我可以正确地做到这一点,但是当我们尝试将它们上传到同一Youtube帐户的另一个频道时,却无法做到(因此OAuth2凭据应该是有效的)。 根据文档,在调用endpoint时,我必须将以下参数传递给API:onBehalfOfContentOwnerChannel和onBehalfOfContentOw

  • 如何使用part:snippet和contentDetails??我想获得持续时间,只有音乐视频,标题和观看次数。请帮助我。

  • 我有一个包含 500 个视频的频道,想要一个包含我频道内所有视频 URL 的列表。 我尝试过: https://gdata.youtube.com/feeds/api/users/default/uploads?key=DEVELOPER_KEY 开发者密钥来自:https://code.google.com/apis/youtube/dashboard 我只是得到:需要用户身份验证。错误 401

  • 我正在使用https://developers.google.com/youtube/的这些API,但是我想不出,给定一个youtube频道地址,如何获得带有相关信息的视频列表(至少是单个视频url和标题)