YouTube API播放项目/列表限制为5000个结果?
我正在尝试从YouTube频道YouTube API播放项目/列表限制为5000个结果?,youtube,youtube-api,youtube-data-api,Youtube,Youtube Api,Youtube Data Api,我正在尝试从YouTube频道machinima获取所有标题的列表。Machinima目前有(我猜这里是)成千上万的视频 下面的Python脚本应该遍历包含播放列表项(播放列表是用户上传的)的页面链 然而,由于某些原因,我最终得到的视频总是不超过5000个 我查看了API文档,但没有此类限制的参考。我使用的代码也来自官方文档(稍加修改),应该可以使用 有人知道我怎样才能从Machinima那里得到所有的视频吗 编辑:10月20日更新。限制似乎已经消失了。我认为这是一个隐含的限制。也许你可以试着指
machinima
获取所有标题的列表。Machinima目前有(我猜这里是)成千上万的视频
下面的Python脚本应该遍历包含播放列表项(播放列表是用户上传的)的页面链
然而,由于某些原因,我最终得到的视频总是不超过5000个
我查看了API文档,但没有此类限制的参考。我使用的代码也来自官方文档(稍加修改),应该可以使用
有人知道我怎样才能从Machinima那里得到所有的视频吗
编辑:10月20日更新。限制似乎已经消失了。我认为这是一个隐含的限制。也许你可以试着指定Machinima的
channelId
并设置type=video
@not\u bot搜索。列表很难限制为500个结果。我认为这是一个隐含的限制。也许你可以改为指定Machinima的channelId
并设置type=video
@not\u bot搜索。列表
很难限制为500个结果。
channels_response = youtube.channels().list(
id=DEFAULT_CHANNEL,
part="contentDetails"
).execute()
if len(channels_response["items"]) == 0:
channels_response = youtube.channels().list(
forUsername=DEFAULT_CHANNEL,
part="contentDetails"
).execute()
for channel in channels_response["items"]:
# From the API response, extract the playlist ID that identifies the list
# of videos uploaded to the authenticated user's channel.
uploads_list_id = channel["contentDetails"]["relatedPlaylists"]["uploads"]
print "Videos in list %s" % uploads_list_id
# Retrieve the list of videos uploaded to the authenticated user's channel.
playlistitems_list_request = youtube.playlistItems().list(
playlistId=uploads_list_id,
part="snippet",
maxResults=50
)
while playlistitems_list_request:
playlistitems_list_response = playlistitems_list_request.execute()
# Print information about each video.
for playlist_item in playlistitems_list_response["items"]:
title = playlist_item["snippet"]["title"]
video_id = playlist_item["snippet"]["resourceId"]["videoId"]
print video_id
videos.append(video_id)
titles.append(title)
playlistitems_list_request = youtube.playlistItems().list_next(
playlistitems_list_request, playlistitems_list_response)