In this tutorial I’ll cover how to build your own youtube video title updater with Node.js. To build this I will be using Youtube Data API. Head over to this link to view my project’s result. The project’s Github repository is available here.
A while back, I watched a Youtube video with the same concept but the person didn’t exactly explain how he did that. So this made me curious and motivated to dig deep inside the Youtube data API.
My goal with this project is to build this youtube video title updater with the greatest ease, and deploy it free of cost online.
Cron: Cron is a time-based job scheduler in Unix-like computer operating systems.
Scheduling: Scheduling is the method by which work is assigned to resources that complete the work.
- A gmail account is required
- Basic programming fundamentals are a must
Step by Step Tutorial
- First of all, head over to this Link and follow the first four steps mentioned there.
NOTE: While creating credentials, you need to select DESKTOP Application type (because there is no other application type option available)
- After that create a .env file which consists of the VIDEO_ID, client_secret and access token which is coming from the first step.
Refer below to check the .env file sample:-
- Now create the server.js file that consists of the authorize and update video title and the get video views functions as shown below:-
Sample .env file below:
server.js file below:-
These functions are pretty much self explanatory. All the parameters are required from the .env file in the first line (using dotenv npm package)
Now run this file using node server.js to check if everything works fine (from turning on youtube data api to updating the title of the video)
4. In order to automate this process of updating the youtube video title using Youtube data API, I will create a cron job.
For this, install two npm packages namely node-cron and shelljs and create the scheduler file as follows:-
Save this file as index.js
Now run node index.js, you will see something like this:
5. Last step is to deploy this project online. There are many places where the project can be deployed, for example: AWS EC2 instance, GCP, Azure, Heroku, Digital Ocean etc.
In order to deploy it free of cost, use heroku and follow the steps:
Learning Tools and Strategies
- Don’t write messy code, everything should be well understood. Doing this will automatically help you when it comes to debugging.
- Do a console.log() at each major step you feel is important, or that you feel may throw some kind of error. This is so that you are able to get the result of each major code-snippet.
- Another thing is to go through the documentation of Youtube data api thoroughly.
- The most important thing to keep in mind is that you need to schedule the cron job in such a way that it runs after every 8 to 9 minutes and not less than that. Because there is a limited daily quota of requests that youtube provides.
youtube, video, title, updater, node, youtube api
I prefer working in a quiet environment so that I am completely focused
It is a very cool project. At first when I saw this I thought it was a hack or glitch or something of that sort. There are many other things that you can do with the youtube data API too, which means the possibilities for future are vast.
The project gives a detailed idea of how to implement a youtube video title updater using Youtube data API and node.js. There are many other things that you can do with the youtube data API. Do play around with this API.
I used https://www.flickr.com/photos/korosirego/4481461680 for the featured image
The project is available here.