So, earlier today, I started a YouTube experiment that involves updating the thumbnail image every 10 minutes. So, I based my Python code off of a code sample from the Google Developers page on youtube.thumbnails.set(): https://developers.google.com/youtube/v3/docs/thumbnails/set
My code looks like this:
def doCredentialStuff():
global youtube
global flow
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
# Get credentials and create an API client
flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
client_secrets_file, scopes)
credentials = flow.run_console(access_type='offline')
youtube = googleapiclient.discovery.build(
api_service_name, api_version, credentials=credentials)
def updateYTthumb(filename):
try:
request = youtube.thumbnails().set(
videoId=VIDEO_ID_UPLOAD,media_body=MediaFileUpload(filename))
response = request.execute()
print(response)
except Exception as exc:
print("ERROR!!!! I got this exception: "+str(exc)+" at time "+str(time.time()))
For my purposes, I want to upload thumbnails every 10 minutes. So, I run doCredentials() only once, at the start of running the code. Then, every 10 minutes, I re-run updateYTthumb(), where it actually executes the request. (This part)
It works perfectly for anywhere from 2 to 12 iterations! (20 - 120 minutes). However, if I let it sit for long enough, it always eventually returns this error:
[WinError 10053] An established connection was aborted by the software in your host machine
I'm not sure how to fix this:
doCredentialStuff(), and then use it during updateYTthumb()?The error is saying that something on your computer interrupted the connection, here are a few things you can try:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With