Youtube API - Set the Thumbnail of Video (python)

2019-02-20 15:43发布

Is it possible to specify your own thumbnail for a video that has been uploaded via the YouTube API?

Using the most recent version of the Python Library, it appears that I can create and set the thumbnail of my media group before inserting a video entry to YouTube - however the thumbnail specified does NOT get set on the video itself.

I'm using code similar to this:

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条回答
We Are One
2楼-- · 2019-02-20 16:21

No. Using the standard YouTube API, you cannot programatically set a thumbnail for your video.

However, if you are a content partner and have access the YouTube CMS (which your partner manager can enable), you can apparently set your video artwork from there. I'll post details as I run through this process.

查看更多
登录 后发表回答