如何通过gdata.youtube API直接方法插入大于1MB的视频

3 投票
1 回答
561 浏览
提问于 2025-04-15 21:25

我正在使用gdata.youtube服务来插入一个视频,但出现了一个错误,提示说文件太大了。其实这个视频并不大,只有1.7MB。在理想情况下,我希望能自然地把文件分成小块,然后逐步上传。请问有没有现成的接口可以做到这一点?

这是我根据谷歌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.

1 个回答

0

Url fetch的请求大小限制为1兆字节,也就是1MB。想了解更多的配额和其他限制,可以查看appengine的文档

撰写回答