我们需要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
但是,这并没有帮助。
我们需要把所有视频发到频道上。上传到一个频道的视频可以来自多个用户,因此我不认为提供用户参数会有帮助…
你必须获得你想要从中获取数据的视频的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。
然后执行。
首先,你需要从用户/频道获取代表上传的播放列表的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}
在最初的问题被问到之后很久才发布,但我做了一个python包,使用一个非常简单的API来做到这一点。它把所有的视频上传到一个频道,但我不确定这一部分(包括在最初的问题中):
上传到一个频道的视频可以来自多个用户,因此我不认为提供用户参数会有帮助…
也许YouTube在这个问题发布后的8年里发生了变化,但如果没有,我制作的软件包可能不包括这个案例。
使用API:
pip3 install -U yt-videos-list # macOS
pip install -U yt-videos-list # Windows
# if that doesn't work, try
python3 -m pip install -U yt-videos-list # macOS
python -m pip install -U yt-videos-list # Windows
然后打开一个python解释器
python3 # macOS
python # Windows
然后运行程序:
from yt_videos_list import ListCreator
lc = ListCreator()
help(lc) # display API information - shows available parameters and functions
my_url = 'https://www.youtube.com/user/1veritasium'
lc.create_list_for(url=my_url)
Python文档(将最频繁地更新,所以请检查此页面的更新!)
库主页
PyPI页面