0

I'm currently using the default settings (which I believe use API v. 1) and the standard youtube-upload python script to upload videos. However, any slight interruption in the network gets the entire upload aborted and it has to start all over from the beginning (plus, I need to clean up the failed uploads..)

Is there a simple way to get such uploads to auto-resume, through repeated connection attempts after each connection disruption? I assume the solution will have to include, among other things, using gdata api v.2

4

1 回答 1

2

您应该试用 V3 api。这是一个示例,其中包括进行可恢复的上传。

https://developers.google.com/youtube/v3/guides/uploading_a_video#Sample_Code

def initialize_upload(options):
  youtube = get_authenticated_service()

  tags = None
  if options.keywords:
    tags = options.keywords.split(",")

  insert_request = youtube.videos().insert(
    part="snippet,status",
    body=dict(
      snippet=dict(
        title=options.title,
        description=options.description,
        tags=tags,
        categoryId=options.category
      ),
      status = dict(
        privacyStatus=options.privacyStatus
      )
    ),
    media_body=MediaFileUpload(options.file, chunksize=-1, resumable=True)
  )

  resumable_upload(insert_request)
于 2012-10-31T16:09:14.177 回答