tokland / youtube-upload

Upload videos to Youtube from the command line
2.09k stars 466 forks source link

resume upload for error 503 #189

Open AndCycle opened 7 years ago

AndCycle commented 7 years ago

according to official doc, I should be able to resume upload for 5xx series error https://developers.google.com/youtube/v3/guides/using_resumable_upload_protocol

here is the error I hit during upload huge 4k files

[RequestError] Server response: {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "backendError",
    "message": "Backend Error"
   }
  ],
  "code": 503,
  "message": "Backend Error"
 }
}
AndCycle commented 7 years ago

and probably also handle Broken pipe error

Traceback (most recent call last):
  File "./runtime/bin/youtube-upload", line 11, in <module>
    load_entry_point('youtube-upload==0.8.0', 'console_scripts', 'youtube-upload')()
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/youtube_upload/main.py", line 264, in run
    sys.exit(lib.catch_exceptions(EXIT_CODES, main, sys.argv[1:]))
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/youtube_upload/lib.py", line 42, in catch_exceptions
    fun(*args, **kwargs)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/youtube_upload/main.py", line 258, in main
    run_main(parser, options, args)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/youtube_upload/main.py", line 181, in run_main
    video_id = upload_youtube_video(youtube, options, video_path, len(args), index)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/youtube_upload/main.py", line 143, in upload_youtube_video
    chunksize=options.chunksize)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/youtube_upload/upload_video.py", line 43, in upload
    RETRIABLE_EXCEPTIONS, max_retries=max_retries)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/youtube_upload/lib.py", line 74, in retriable_exceptions
    raise exc
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/youtube_upload/lib.py", line 70, in retriable_exceptions
    return fun()
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/youtube_upload/upload_video.py", line 41, in <lambda>
    upload_fun = lambda: _upload_to_request(request, progress_callback)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/youtube_upload/upload_video.py", line 25, in _upload_to_request
    status, response = request.next_chunk()
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/googleapiclient/http.py", line 972, in next_chunk
    headers=headers)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/oauth2client/transport.py", line 175, in new_request
    redirections, connection_type)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/oauth2client/transport.py", line 282, in request
    connection_type=connection_type)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/httplib2/__init__.py", line 1322, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/httplib2/__init__.py", line 1072, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/home/andcycle/proj/youtube-upload/runtime/lib/python3.4/site-packages/httplib2/__init__.py", line 996, in _conn_request
    conn.request(method, request_uri, body, headers)
  File "/usr/lib64/python3.4/http/client.py", line 1137, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib64/python3.4/http/client.py", line 1182, in _send_request
    self.endheaders(body)
  File "/usr/lib64/python3.4/http/client.py", line 1133, in endheaders
    self._send_output(message_body)
  File "/usr/lib64/python3.4/http/client.py", line 967, in _send_output
    self.send(message_body)
  File "/usr/lib64/python3.4/http/client.py", line 926, in send
    self.sock.sendall(datablock)
  File "/usr/lib64/python3.4/ssl.py", line 720, in sendall
    v = self.send(data[count:])
  File "/usr/lib64/python3.4/ssl.py", line 681, in send
    v = self._sslobj.write(data)
BrokenPipeError: [Errno 32] Broken pipe