top of page

Displaying the most recent comment on the video's thumbnail automatically.

In this post, I'm going to teach you how to make your YouTube video's thumbnail update with its comments, that is, display a recent comment on the thumbnail and update the thumbnail frequently.


Before starting, let me make it clear that it's no magic, it's just basic programming. You can use any language you wish but I'll be using Python.







Create a Google Cloud Project


We're going to use YouTube Data API v3 for this script. So you need to create an account on Google Cloud Platform, create a project (call it whatever you like) and enable YouTube Data API v3 from the API & Services dashboard.


Now that you enabled the required API, you need to create an API Key and an OAuth Client ID.


..Why?


An API key is mandatory when you are making requests to the YouTube Data API, it allows Google to track who is making requests to their APIs.


OAuth is an advanced authorization protocol. It allows users to see/choose what permissions they are giving to a particular app. In our case, since our app needs to update the thumbnail of a video, we will need to authorize our app from a valid end-point (i.e., from the channel on which the video is uploaded or a manager account of this channel).

For example, consider TubeBuddy. When you are logging in to TubeBuddy you are presented with this screen which displays what permissions this app is requesting from you, this is nothing but OAuth authorization.


ree





Creating an API key


In your Google Cloud Platform dashboard,

  • Go to API & Services -> Credentials

  • Click 'Create credentials' on the top and select 'API key' from the drop-down

An API key will be generated.



Creating OAuth Client ID

To create an OAuth Client ID for your app, you first need to configure an OAuth consent screen.

  • Go to API & Services -> OAuth Consent Screen

  • Choose External and click create


ree
  • Submit the necessary details asked on the next page. It's basically your App name, developer contact email, etc.


ree
  • In the Scopes menu, add the scope 'https://www.googleapis.com/auth/youtube.force-ssl'


ree
  • In the Test Users menu, add your email ID (channel owner or manager)


ree

That's it, you configured the OAuth Consent Screen for your app.


Now, in order to create an OAuth Client ID,

  • Go to APIs & Services -> Credentials

  • Click Create Credentials on the top, and select OAuth Client ID from the drop down


ree

  • Select the Application type as 'Web application', and give your app a name.

ree

ree

  • You've now created your OAuth Client ID, download your ID and secret in JSON.

ree

Alright, now you have an app that is waiting for your channel's authorization so that it will be able to update your thumbnails on your behalf.

To continue with the authorization process,

pip install -r requirements.txt
  • Place the downloaded client secret json file in the same folder as main.py and rename the file to client_secret.json

  • Run the server

python main.py

Now open your browser and go to http://127.0.0.1:8080


This will bring up a page like this,


ree

This web app basically helps you to generate credentials for your app to use. These credentials are not your username and password, they are your OAuth Credentials that can be made use by Google Apps to manage your account on your behalf. In this case, we want to give authorization to our app so that it can update thumbnails on a video(s).





Click 'Test the auth flow directly' on the web page.


This will create a credentials.txt file in your current working directory. These are the credentials that the app needs.


Purrrfect, now we have everything that we need to start our script.


Clone this GitHub repo


This is the script that can retrieve a recent comment from your video and then change the thumbnail such that it displays this recent comment.


  • Install the required modules

pip install -r requirements.txt
  • Place the credentials.txt and client_secret.json files in the same folder as bot.py

  • Open bot.py and change the VIDEO_ID variable to your video ID.

VIDEO_ID = '' #Put your video id here
  • Change the DEVELOPER_KEY variable to your API KEY

DEVELOPER_KEY = '' #Put your API key here


That's it, now just run the script.

python bot.py

This will start the script which will automatically retrieve a recent comment, write it on the template image, and set this image as the thumbnail. It does so every 8 minutes.



ree


This 8 minute is a calculated number considering the maximum allowed quota for YouTube Data API is 10,000 units per day and the cost for updating the thumbnail every time is 50 units. The idea is that the bot can update the thumbnail 180 times a day (by using 180*50 = 9,000 units of quota) at a rate of 1 update every 8 minutes.


Now, just run this script on the cloud (like Google Cloud, Heroku, Azure, whatever you like!). I'm personally running it on google cloud for now. Costs around 600/month for the VM instance but I'm sure there are some free alternatives (like pythonanywhere but I don't know if this script works there, gotta try).



19 Comments


Daisy wadhwa
Daisy wadhwa
5 days ago

I like how the Okwin Lottery gives everyone a fair chance to win big. OK Win || OK Win Login || OK Win Game || OKWin

Like

Daisy wadhwa
Daisy wadhwa
5 days ago

Great recommendation! BG678 turned out to be exactly what I needed. bg678 Login

Like

Daisy wadhwa
Daisy wadhwa
5 days ago

I’ve had a really positive experience using Tashanwin, everything runs smoothly. Tashan Win Game || Tashan Win Login || Tashan Win

Like

Daisy wadhwa
Daisy wadhwa
5 days ago

GoaGame keeps updating features regularly which makes the app more reliable. Goa Game || Goa Game Login

Like

Hyderabad, the City of Pearls, is known for its culture, cuisine, and vibrant lifestyle. Alongside its architectural wonders and bustling business hubs, the city also offers exclusive companionship services through Hyderabad call girls. These services are discreet, elegant, and tailored for individuals who seek refined experiences, whether for social gatherings, private events, or moments of personal relaxation.


Hyderabad offers one of the most refined and professional escort services in India. The call girls in Hyderabad bring together beauty, intellect, and discretion, making them the perfect choice for clients who seek companionship beyond ordinary experiences. Whether it’s for business, leisure, or personal fulfillment, they deliver moments that stay cherished forever.


Read More :- Call Girls Hyderabad | Call Girls Agra | Call Girl Ahmedabad | Call Girl Ajmer | Call Girl…

Like

© 2019 Tech Raj. Designed by Teja Swaroop

  • YouTube
  • Facebook Page
  • Twitter
bottom of page