Upload a video to Youtube using the python API and

2019-07-11 16:15发布

I'm using the python client library to upload videos to youtube.

I need to the set it's privacy as unlisted, but the API page only shows examples of how to set them as private.

Anyone knows how to change the privacy control of these videos?

Thanks!

1条回答
手持菜刀,她持情操
2楼-- · 2019-07-11 16:56

The XML element that you need is described in http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_yt:accessControl

Following the API documentation, you can build this element as follows:

from gdata.media import YOUTUBE_NAMESPACE
from atom import ExtensionElement

# set video as unlisted
kwargs = {
    "namespace": YOUTUBE_NAMESPACE,
    "attributes": {'action': 'list', 'permission': 'denied'},
}
extension = ([ExtensionElement('accessControl', **kwargs)])

# create the gdata.youtube.YouTubeVideoEntry
video_entry = gdata.youtube.YouTubeVideoEntry(media=my_media_group,
    geo=where, extension_elements=extension)
查看更多
登录 后发表回答