I want to use Youtube API to upload a video on youtube but it is not working. I read the same question Youtube Data API V3 returning ssl.SSLWantWriteError: The operation did not complete (write) error but it is not working with a solution on this question. But I know that If I have a 1 minute-long video is any problem here but if I have a 1 hour long video this error came.
File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapperreturn wrapped(*args, **kwargs)File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\googleapiclient\http.py", line 923, in execute resp, content = _retry_request( File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\googleapiclient\http.py", line 222, in _retry_request raise exception File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\googleapiclient\http.py", line 191, in _retry_request resp, content = http.request(uri, method, *args, **kwargs) File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\google_auth_httplib2.py", line 218, in request response, content = self.http.request( File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\httplib2\__init__.py", line 1725, in request (response, content) = self._request( File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\httplib2\__init__.py", line 1441, in _request (response, content) = self._conn_request(conn, request_uri, method, body, headers) File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\httplib2\__init__.py", line 1364, in _conn_request conn.request(method, request_uri, body, headers) File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1255, in request self._send_request(method, url, body, headers, encode_chunked) File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1301, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1250, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1049, in _send_output self.send(chunk) File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 971, in send self.sock.sendall(data) File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 1204, in sendall v = self.send(byte_view[count:]) File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 1173, in send return self._sslobj.write(data)ssl.SSLWantWriteError: The operation did not complete (write) (_ssl.c:2473)
here is my code:
import datetimefrom Google import Create_Servicefrom googleapiclient.http import MediaFileUploadCLIENT_SECRET_FILE = 'youtube_client.json'API_NAME = 'youtube'API_VERSION = 'v3'SCOPES = ['https://www.googleapis.com/auth/youtube.upload']service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES)upload_date_time = datetime.datetime(2022, 12, 25, 12, 30, 0).isoformat() +'.000Z'request_body = {'snippet': {'categoryI': 10,'title': 'best music on the youtube | happy mood mix | AMP','description': "test",'tags': ['Travel', 'video test', 'Travel Tips'] },'status': {'privacyStatus': 'private','publishAt': upload_date_time,'selfDeclaredMadeForKids': False, },'notifySubscribers': False}mediaFile = MediaFileUpload('output.mp4')response_upload = service.videos().insert( part='snippet,status', body=request_body, media_body=mediaFile).execute()