How I Automated a YouTube Thumbnail With Python (US Election Vote Counts)

Published September 12, 2020

In this article, I talk about how to automate a YouTube Thumbnail with Python. I took some inspiration from the recent US Elections.

Given the votes are still being counted, I thought it would be quite cool. Could I automate the generation and upload of a thumbnail that would show the vote counts for both Biden and Trump.

Now a quick side note. If you’re learning Python and need some help, check out this book here. It’s probably the best book to learn Python and sits proudly on my bookshelf.

How MrBeast Automated his YouTube Thumbnail

Not long ago, I made a video about how Mr Beast did this with his video thumbnail.

In the video, he planned to give away an increasing amount of money to his friend. The amount was based on the number of clicks that video received.

Now you’re probably wondering, how did he go about doing this. Surely the amount would change frequently as more people clicked the video? Did he update it manually for every click?

The short answer is No.

The long answer is that he automated the update and change of this thumbnail with a program. One that ran on a schedule and in the background. In a previous video, I explained how he went about doing it. I also replicated it myself :) You can check that video out here:

As Biden and Trump battle for the Democrats and Republicans respectively, the votes are changing daily. There are many still left to be counted in different states. Despite the protests by Trump to “STOP THE COUNT”, it continues.

Biden Trump Vote Counts

With that said, I wanted to see if I could show the latest vote counts on a YouTube thumbnail. But more importantly, could I automatically update and change it. I had to do some digging. Specifically, I had to find an API to get the latest counts. This required a bit of blackbox investigation as most of these APIs are behind a paywall. Google for example are using the Associated Press API to get the latests counts. This as you can imagine costs a fair bit of money.

Nevertheless, I dabbled away and found one. Not only did it give the latest number of votes, but it also broke them down by each state. Super useful, but for this tutorial we kept it simple!

Associated Press API US Vote Counts

The rest of the steps required getting familiar with Pillow, a popular Python library for editing images. I also had to integrate the YouTube Data API that provides capabilities to programmatically change the thumbnails for YouTube videos.

The Final Result

Putting these together, I was able to automate the entire process. This program automates the creation, upload and change of a YouTube thumbnail with Python. The thumbnail of course in this instance has the latest vote counts.

Here’s the final result of what the thumbnail looks like, though, as you can imagine, it is currently updating…

For more Python and Programming tutorials, check out my YouTube channel.

Source Code & Links: Click here

You can also reach me on my Instagram, YouTube and TikTok.