使用 youtube API 获取频道的所有视频 [英] Getting all videos of a channel using youtube API

查看:40
本文介绍了使用 youtube API 获取频道的所有视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取我有 ID 的单个频道的所有视频.我只获取频道信息的问题.这是我正在使用的链接:

I want to get all videos of a single channel that i have its Id. The problem that I am getting only the channel informations. this is the link that I am using:

https://gdata.youtube.com/feeds/api/users/UCdCiB_pNQpR0M_KkDG4Dz5A?v=2&alt=json&q=goal&orderby=published&max-results=10

推荐答案

该链接用于现已停用的 V2 API,因此它不会返回任何数据.相反,您需要使用 API 的 V3.您需要做的第一件事是注册一个 API 密钥——您可以通过在 console.developers.google 上创建一个项目来完成此操作.com,将 YouTube 数据 API 设置为开启",并创建公共访问密钥.

That link is for the now-retired V2 API, so it will not return any data. Instead, you'll want to use V3 of the API. The first thing you'll need to do is register for an API key -- you can do this by creating a project at console.developers.google.com, setting the YouTube data API to "on," and creating a public access key.

由于您已经拥有用户频道 ID,您可以直接从中获取视频;但是请注意,如果您不知道频道 ID,可以通过以下方式获取:

Since you have your user channel ID already, you can jump right into getting the videos from it; note, however, that if you ever don't know the channel ID, you can get it this way:

https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername={username}&key={YOUR_API_KEY}

通过频道 ID,您可以通过搜索端点获取频道中的所有视频,如下所示:

With the channel ID, you can get all the videos from the channel with the search endpoint, like this:

https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId={channel id here}&maxResults=25&key={YOUR_API_KEY}

在这种情况下,按日期排序与按已发布"排序的旧 V2 参数相同.

In this case, ordering by date is the same as the old V2 parameter for ordering by "published."

在搜索频道时,您还可以使用许多其他参数来检索视频;请参阅 https://developers.google.com/youtube/v3/docs/search/list了解更多详情.

There are also a lot of other parameters you can use to retrieve videos while searching a channel; see https://developers.google.com/youtube/v3/docs/search/list for more details.

这篇关于使用 youtube API 获取频道的所有视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆