我们需要YouTube的频道名称的视频列表(使用API)。

我们可以通过下面的API获得一个频道列表(只有频道名):

https://gdata.youtube.com/feeds/api/channels?v=2&q=tendulkar

下面是频道的直接链接

https://www.youtube.com/channel/UCqAEtEr0A0Eo2IVcuWBfB9g

Or

WWW.YouTube.com/channel/HC-8jgBP-4rlI

现在,我们需要>> UCqAEtEr0A0Eo2IVcuWBfB9g或HC-8jgBP-4rlI频道的视频。

我们尝试

https://gdata.youtube.com/feeds/api/videos?v=2&uploader=partner&User=UC7Xayrf2k0NZiz3S04WuDNQ https://gdata.youtube.com/feeds/api/videos?v=2&uploader=partner&q=UC7Xayrf2k0NZiz3S04WuDNQ

但是,这并没有帮助。

我们需要把所有视频发到频道上。上传到一个频道的视频可以来自多个用户,因此我不认为提供用户参数会有帮助…


当前回答

Python中的示例解决方案。从这个视频中得到帮助:视频 与许多其他答案一样,上传id首先从通道id中检索。

import urllib.request
import json

key = "YOUR_YOUTUBE_API_v3_BROWSER_KEY"

#List of channels : mention if you are pasting channel id or username - "id" or "forUsername"
ytids = [["bbcnews","forUsername"],["UCjq4pjKj9X4W9i7UnYShpVg","id"]]

newstitles = []
for ytid,ytparam in ytids:
    urld = "https://www.googleapis.com/youtube/v3/channels?part=contentDetails&"+ytparam+"="+ytid+"&key="+key
    with urllib.request.urlopen(urld) as url:
        datad = json.loads(url.read())
    uploadsdet = datad['items']
    #get upload id from channel id
    uploadid = uploadsdet[0]['contentDetails']['relatedPlaylists']['uploads']

    #retrieve list
    urld = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails&maxResults=50&playlistId="+uploadid+"&key="+key
    with urllib.request.urlopen(urld) as url:
        datad = json.loads(url.read())

    for data in datad['items']:
        ntitle =  data['snippet']['title']
        nlink = data['contentDetails']['videoId']
        newstitles.append([nlink,ntitle])

for link,title in newstitles:
    print(link, title)

其他回答

使用已弃用的API版本2,用于上传的URL(通道UCqAEtEr0A0Eo2IVcuWBfB9g)是:

https://gdata.youtube.com/feeds/users/UCqAEtEr0A0Eo2IVcuWBfB9g/uploads

有一个API版本3。

你必须获得你想要从中获取数据的视频的channel_id。

为了通过video_id获得channel_id,你可以使用YouTube数据API的videos:list端点-在Id参数中添加video_id。的例子。

然后,使用channel_id,将第二个字符更改为“U”:

这个修改后的id是上传播放列表说YouTube频道。

有了这个Uploads playlist_id,你可以使用YouTube数据API的Playlistitem:list端点从频道检索所有上传的视频。

在部分参数中添加“id,snippet,contentDetails,status”。 并在playlistID中添加修改后的通道ID。 然后执行。

你需要看看YouTube数据API。您将在那里找到关于如何访问API的文档。您还可以找到客户端库。

你也可以自己提出要求。下面是一个从频道检索最新视频的示例URL:

https://www.googleapis.com/youtube/v3/search?key={your_key_here}&channelId={channel_id_here}&part=snippet,id&order=date&maxResults=20

之后,你会收到一个包含视频id和详细信息的JSON,你可以像这样构建你的视频URL:

http://www.youtube.com/watch?v={video_id_here}

首先,你需要从用户/频道获取代表上传的播放列表的ID:

https://developers.google.com/youtube/v3/docs/channels/list#try-it

您可以使用forUsername={username}参数指定用户名,或者使用mine=true来获得自己的用户名(您需要先进行身份验证)。Include part=contentDetails查看播放列表。

GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=jambrose42&key={YOUR_API_KEY}

结果“relatedPlaylists”将包括“likes”和“uploads”播放列表。抓取“上传”播放列表ID。

还要注意,上传播放列表id是你的channelId,前缀是UU而不是UC。

接下来,获取播放列表中的视频列表:

https://developers.google.com/youtube/v3/docs/playlistItems/list#try-it

只需要输入playlistId!

GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails&maxResults=50&playlistId=UUpRmvjdu3ixew5ahydZ67uA&key={YOUR_API_KEY}

获取频道列表:

通过forUserName获取频道列表:

https://www.googleapis.com/youtube/v3/channels?part=snippet,contentDetails,statistics&forUsername=Apple&key=

按频道id获取频道列表:

https://www.googleapis.com/youtube/v3/channels/?part=snippet,contentDetails,statistics&id=UCE_M8A5yxnLfW0KghEeajjw&key=

获取通道部分:

https://www.googleapis.com/youtube/v3/channelSections?part=snippet,contentDetails&channelId=UCE_M8A5yxnLfW0KghEeajjw&key=

获取播放列表:

按频道ID获取播放列表:

https://www.googleapis.com/youtube/v3/playlists?part=snippet,contentDetails&channelId=UCq-Fj5jknLsUf-MWSy4_brA&maxResults=50&key=

使用pageToken通过频道ID获取播放列表:

https://www.googleapis.com/youtube/v3/playlists?part=snippet,contentDetails&channelId=UCq-Fj5jknLsUf-MWSy4_brA&maxResults=50&key=&pageToken=CDIQAA

获取PlaylistItems:

通过PlayListId获取PlaylistItems列表:

https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,contentDetails&maxResults=25&playlistId=PLHFlHpPjgk70Yv3kxQvkDEO5n5tMQia5I&key=

获取视频:

通过视频id获取视频列表:

https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id=YxLCwfA1cLw&key=

通过多个视频id获取视频列表:

https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id=YxLCwfA1cLw,Qgy6LaO3SB0,7yPJXGO2Dcw&key=

获取评论列表

按视频ID获取评论列表:

https://www.googleapis.com/youtube/v3/commentThreads?part=snippet replies&videoId = el * * * * kQak&key = ********** k

按频道ID获取评论列表:

https://www.googleapis.com/youtube/v3/commentThreads?part=snippet replies&channelId = U * * * * * q键= AI * * * * * * * * k

通过allThreadsRelatedToChannelId获取评论列表:

https://www.googleapis.com/youtube/v3/commentThreads?part=snippet replies&allThreadsRelatedToChannelId =加州大学* * * * * ntcQ&key = AI * * * * * k

这里所有的api都是Get方法。

基于频道id,我们不能直接得到所有的视频,这是这里的重点。

对于集成https://developers.google.com/youtube/v3/quickstart/ios?ver=swift