本文介绍了从 YouTube 频道获取视频列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这些 API https://developers.google.com/youtube/我不知道如何在给定 youtube 频道地址的情况下获取包含相关信息的视频列表(至少是单个视频网址和标题)

I'm using these apis https://developers.google.com/youtube/and I can't figure out how, given a youtube channel address, get the video list with related infos (single video url and title, at least)

推荐答案

这有点复杂,但可以相对轻松地完成.诀窍在于知道频道实际上只是特定用户上传的视频列表.因此,如果当您说您有一个 youtube 频道地址时,该地址采用以下形式:

It's a bit convoluted, but can be done relatively painlessly. The trick is in knowing that a channel is really just a list of videos uploaded by a particular user. So if, when you say you have a youtube channel address, that address takes the form of:

http://www.youtube.com/user/[username]

然后您可以使用用户上传的提要获取视频:

Then you can get the videos with the user uploads feed:

https://gdata.youtube.com/feeds/api/users/[username]/uploads

附带说明,如果您使用提要:

As a side note, if you use the feed:

https://gdata.youtube.com/feeds/api/users/[username]

您将获得有关用户的额外信息,包括一系列元素,这些元素为您提供各种提要链接(其中一个是我上面提到的上传提要),其中还包含视频数量等信息.

You'll get back extra info about the user, including a series of elements that give you various feed links (one of which is the uploads feed I mentioned above) that also contain info such as number of videos, etc.

如果您的频道网址采用以下形式:

If instead your channel URL is in the form:

https://www.youtube.com/channel/UC[userid]

请注意,这种 URL 总是以 UC 开头,然后是一个长字符串.在这种情况下,只需放下 UC,然后访问此提要:

Note that this kind of URL always starts with UC and then a long string. In this case, just drop the UC, and visit this feed:

https://gdata.youtube.com/feeds/api/users/[userid]/uploads

这篇关于从 YouTube 频道获取视频列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:38