Skip to main content
 首页 » 编程设计

python之如何使用 gdata.youtube api 直接方法插入大于 1MB 的视频

2025年05月04日8wuhuacong

我正在使用 gdata.youtube 服务插入视频条目。它因 url 提取错误而失败,提示文件太大。这是一个非常小的视频 (1.7MB)。在理想情况下,有一种自然的方式可以根据需要分解文件并将其分块流式传输。是否已经有一个 API 可以执行此操作。

这是我根据 google api 教程使用的代码:

my_media_group = gdata.media.Group( 
        title=gdata.media.Title(text='My Test Movie'), 
        description=gdata.media.Description(description_type='plain', 
                                  text='My description'), 
        keywords=gdata.media.Keywords(text='cars, funny'), 
        category=[gdata.media.Category(text='Autos',  scheme='http://gdata.youtube.com/schemas/2007/categories.cat', label='Autos')], 
        player=None 
        ) 
 
    where = gdata.geo.Where() 
    where.set_location((37.0,-122.0)) 
 
    # create the gdata.youtube.YouTubeVideoEntry to be uploaded 
    video_entry = gdata.youtube.YouTubeVideoEntry(media=my_media_group, 
                                          geo=where) 
 
    new_entry = self.client.InsertVideoEntry(video_entry, 'movie.mov') 

这里是错误:

RequestTooLargeError: The request to API call urlfetch.Fetch() was too large. 

请您参考如下方法:

Url fetch 的请求大小限制为 1 兆字节。检查appengine docs配额和其他限制