def get_videos(search_keyword):
youtube = build(YOUTUBE_API_SERVICE_NAME,
YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY)
try:
search_response = youtube.search().list(
q=search_keyword,
part="id,snippet",
channelId=os.environ.get("CHANNELID", None),
maxResults=10, #max = 50, default = 5, min = 0
).execute()
videos = []
channels = []
for search_result in search_response.get("items", []):
if search_result["id"]["kind"] == "youtube#video":
title = search_result["snippet"]["title"]
videoId = search_result["id"]["videoId"]
channelTitle = search_result["snippet"]["channelTitle"]
cam_thumbnails = search_result["snippet"]["thumbnails"]["medium"]["url"]
publishedAt = search_result["snippet"]["publishedAt"]
channelId = search_result["snippet"]["channelId"]
data = {'title' : title,
'videoId' : videoId,
'channelTitle' : channelTitle,
'cam_thumbnails' : cam_thumbnails,
'publishedAt' : publishedAt}
videos.append(data)
elif search_result["id"]["kind"] == "youtube#channel":
channels.append("%s (%s)" % (search_result["snippet"]["title"],
search_result["id"]["channelId"]))
except Exception as e:
print e
现在,我正在使用pythonyoutube数据api,我得到指定频道中按关键字搜索的youtube视频数据,但我希望获得指定频道中没有按关键字搜索的所有数据
如何在指定频道获取youtube视频数据?我要获取的数据必须是指定通道中的所有数据
我不能百分之百地确定我知道你在问什么,但我想你是在问你如何才能在一个频道里得到所有的视频,而不仅仅是那些与关键词相关的视频?如果是正确的,您应该能够删除:
根据您的请求,API应该返回频道中的所有视频。如果你在问别的问题,请在你的问题中澄清。在
相关问题 更多 >
编程相关推荐