-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcode.js
More file actions
30 lines (26 loc) · 1.06 KB
/
code.js
File metadata and controls
30 lines (26 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const express = require("express");
const ytdl = require("ytdl-core");
const app = express();
const path = require('path')
app.use(express.json());
app.use(express.static("public"));
app.use('/css', express.static(path.join(__dirname, 'node_modules/bootstrap/dist/css')))
app.use('/js', express.static(path.join(__dirname, 'node_modules/bootstrap/dist/js')))
app.use('/js', express.static(path.join(__dirname, 'node_modules/jquery/dist')))
app.get("/",function(request,response){
response.sendFile(__dirname + "public/index.html");
});
app.get("/videoInfo",async function(request,response){
const videoURL = request.query.videoURL;
const info = await ytdl.getInfo(videoURL);
response.status(200).json(info);
});
app.get("/download",function(request,response){
const videoURL = request.query.videoURL;
const itag = request.query.itag;
response.header("Content-Disposition",'attachment;\ filename="video.mp4"');
ytdl(videoURL,{
filter: format => format.itag == itag
}).pipe(response);
});
app.listen(5000);