How to Make Your Own Youtube Video Downloader Using Express js and ytdl ..........

HELLO FRIENDS......This is The Post About How to Make Youtube Video Downloader (For Website Purpose) Using Express JS . IF You Don't Know How to Make Youtube Video Downloader Then This  Post  is For You . So Check Out Full Post......


Page Content : 


Use Of Youtube Video Downloader
Which NPM Package is Required To Install
Express JS With Example 
HTML Code With Example
Testing Of YOUTUBE VIDEO DOWNLOADER


How_to_Make_Your_Own_Youtube_Video_Downloader_Using_Express_js_and_ytdl


USE OF YOUTUBE VIDEO DOWNLOADER :


By Using this Youtube Video Downloader , Download Youtube Video From Url . So this is HelpFul For All. For Making Youtube Video Downloader It Requires Some HTML, CSS and Node js Or Express JS File.  



Some NPM Package is Required to Install in Your Main Folder to Make Youtube Video Downloader.... :


Before Installing This Package Run This Command : npm init

1) Express  - https://www.npmjs.com/package/express (npm install express)

2) ytld core - https://www.npmjs.com/package/ytdl-core (npm install ytdl-core@latest)


ytdl-core is a module that can be installed in your node project. It allows you to download youtube videos. ytdl-core has So Many Features Like ytdl.videoInfo which Gives Different information About Youtube Video.



After Installing This Package of Your Main Project Folder We Need To Make One  index.js File Now index.js File Code is.... 



const express = require("express"); const app = express(); const path = require("path"); const fs = require("fs"); const ytdl = require('ytdl-core'); const mainpath = path.join(__dirname,"../YOUTUBE VIDEO DOWNLOADER"); const indexfile = fs.readFileSync("index.html","utf-8"); app.use(express.static(mainpath)); app.get("/",(req,res)=>{ res.send("Hello World"); }) app.listen(8000,()=>{ console.log("Server Stared Successfully"); });


 






Now Add ytdl-core Command To index.js File






app.get("/download",(req,res)=>{



   res.header("Content-Disposition", 'attachment;\  filename="Youtube Video.mp4')



    ytdl(req.query.url ,{format:'mp4'})



    .pipe(res)



   });


Your Hole index.js File is : 





const express = require("express");

const app = express();

const path = require("path");

const fs = require("fs");

const ytdl = require('ytdl-core');

const mainpath = path.join(__dirname,"../YOUTUBE VIDEO DOWNLOADER");

const indexfile = fs.readFileSync("index.html","utf-8");

app.use(express.static(mainpath));

app.get("/",(req,res)=>{

    res.send("Hello World");


});

app.get("/download",(req,res)=>{

   res.header("Content-Disposition", 'attachment;\  filename="Youtube Video.mp4')

    ytdl(req.query.url ,{format:'mp4'})

    .pipe(res)


   });

app.listen(8000,()=>{

  console.log("Server Stared Successfully");


});



When The User Send get Request to The Server at the path /download then the server will respond with the query inserted with the request.



Also Read This :


How to Make Your Own XML SITEMAP GENERATOR Using Express js..........


Top Most Funny and Amazing APIS जानिए हिंदी में........

How to Set Preloader In Your Website Using Javascript.......



After Making index.js File Make One HTML File To Get Input Youtube Link From Any User So index.html File is ....






<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Youtube video Downloader</title>

   

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">



<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap">



<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet">



<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.19.1/css/mdb.min.css" rel="stylesheet">

    <style>

        h3{

            text-align: center;

        }

        .box{

            text-align: center;

        }

     #myinput{

         margin:auto;

     }

    

    </style>

</head>

<body>

    <div class="container">

        <h3 style="margin-top:30px;">Youtube Video Downloader</h3>

        <form action="http://localhost:8000/download/" method="GET">

            <div class="form-group">

                <input id="myinput" class="form-control" type="text" name="url" name="videourl" placeholder="https://www.youtube.com/watch?v=linlz7-Pnvw" required />

            </div>

            <div class="form-group text-center">

          <button class="btn btn-mdb-color" value="Submit" type="submit" id="btn">Download</button>

            </div>

        </form>

    </div>



<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>



<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.4/umd/popper.min.js"></script>



<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/js/bootstrap.min.js"></script>



<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.19.1/js/mdb.min.js"></script>

</body>

</html>

          



After Making This Two Files Start Server Using nodemon index.js or Else node index.js . Now you Show This Type of Front end :






                    

Now Copy Any Youtube Link And Try It by

Yourself

(You Can Also Add Some CSS to make

interactive)

Conclusion

This is All About How to Make Your Own Youtube Video Downloader Using Express js and ytdl. if You Like This Article Then Share with Your Friends and Family.


I HOPE THAT THIS POST IS HELPFUL FOR YOU.


THANKYOU FOR READING. 


TAGS :HTML , EXPRESS JS ytdl , make your own youtube video downloader


About Author : 


Hello friends, I am Abhi Patel author & founder of Technovichar.com. I am a student of IT engineering. I like to research and write about new things even if it is from any field. You will continue to support us in this way, we will keep on bringing such interesting information for you.

Post a Comment

1 Comments