Youtube API - 设置视频缩略图(Python)
通过YouTube API上传视频时,可以指定自己的缩略图吗?
使用最新版本的Python库,我似乎可以在将视频信息插入YouTube之前,创建并设置我的媒体组的缩略图——但是指定的缩略图并没有被应用到视频上。
我使用的代码类似于这个:
from gdata import media
from gdata.youtube import YouTubeVideoEntry
from gdata.youtube.service import YouTubeService
# Create a thumbnail and pass it to my media group
thumbnail = media.Thumbnail(url='http://valid_image_url.jpg')
media_group = media.Group(thumbnail=thumbnail, title='foo', ...)
# Use the media group to create a video entry
entry = YouTubeVideoEntry(media=media_group)
# Create a service instance and use it to login
service = YouTubeService(...)
service.ClientLogin(...)
# Get video file
file = open('/path_to_video.mp4', 'rb')
# Push the video to YouTube
service.InsertVideoEntry(
entry,
file
)
# Close the file
file.close()
1 个回答
1
不可以。 使用标准的YouTube API,你无法通过编程的方式为你的视频设置缩略图。
不过,如果你是内容合作伙伴,并且可以访问YouTube CMS(你的合作伙伴经理可以帮你开启这个权限),那么你就可以从那里设置你视频的封面图。我会在这个过程中分享更多细节。