Youtube is the most famous video streaming website now days even 98% of people in this world are using youtube, even the android mobile has built-in youtube installed from google. I think that’s the fact youtube is the most popular product of Google, Let move to our today’s topic, Youtube Downloader in JavaScript. So we are going to walk through that how to develop a youtube downloader that downloads any youtube video or playlist on your computer, we can use any programming language for this python, C++ even java. But I love JavaScript so I will go with it, well without wasting time let’s jump into the things we need to start the coding.We need NodeJs to compile the JavaScript code, if you already had NodeJs installed that good you can move to the library installation part or not just download the latest version NodeJs and install it on your windows, Linux, or any operating system you had. Next we need a JavaScript module name**_ youtube-dl,_**copy that below command and paste it in the command prompt.

_npm i youtube-dl_

Coding Part

Create a youtube.js file and open it in your code editor, let start with importing the library of youtube-dl in our script.

const fs = require('fs')
const youtubedl = require('youtube-dl')
 
const video = youtubedl('http://www.youtube.com/watch?v=90AiXO1pAiA',
  // Optional arguments passed to youtube-dl.
  ['--format=18']
)

first-line we are loading the fs module in the const variable fs, that module is basically used for reading and writing video files, In the next line, we are loading our main module in const variable youtube-dl. After we loading the required modules we just use youtubedl() function in which we are passing youtube video URL, and format. Note we are setting the format number to 18 which is 320p mp4 format, if you want to set HD format or any format you loved in youtube videos visit theyoutube_format_number.  Let move to another part of the program is downloading the video check the code below.

#youtube #javascript #nodejs

How to Create Youtube Downloader in Javascript
85.35 GEEK