mirror of
https://github.com/SrIzan10/youtubeDownloader.git
synced 2026-05-01 11:06:58 +00:00
tried
This commit is contained in:
12
index.js
12
index.js
@@ -14,9 +14,6 @@ app.listen(PORT, err => {
|
||||
app.get('/downloadmp3', async (req, res, next) => {
|
||||
try {
|
||||
var url = req.query.url;
|
||||
if(!ytdl.validateURL(url)) {
|
||||
return res.sendStatus(400);
|
||||
}
|
||||
let title = 'audio';
|
||||
|
||||
await ytdl.getBasicInfo(url, {
|
||||
@@ -39,20 +36,17 @@ app.get('/downloadmp3', async (req, res, next) => {
|
||||
|
||||
app.get('/downloadmp4', async (req, res, next) => {
|
||||
try {
|
||||
let url = req.query.url;
|
||||
if(!ytdl.validateURL(url)) {
|
||||
return res.sendStatus(400);
|
||||
}
|
||||
let URL = req.query.url;
|
||||
let title = 'video';
|
||||
|
||||
await ytdl.getBasicInfo(url, {
|
||||
await ytdl.getBasicInfo(URL, {
|
||||
format: 'mp4'
|
||||
}, (err, info) => {
|
||||
title = info.player_response.videoDetails.title.replace(/[^\x00-\x7F]/g, "");
|
||||
});
|
||||
|
||||
res.header('Content-Disposition', `attachment; filename="${title}.mp4"`);
|
||||
ytdl(url, {
|
||||
ytdl(URL, {
|
||||
format: 'mp4',
|
||||
}).pipe(res);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user