mirror of
https://github.com/SrIzan10/youtubeDownloader.git
synced 2026-05-01 11:06:58 +00:00
fix-2
This commit is contained in:
@@ -1,49 +1,47 @@
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const ytdl = require('ytdl-core');
|
||||
const express = require("express");
|
||||
const cors = require("cors");
|
||||
const ytdl = require("ytdl-core");
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(cors());
|
||||
|
||||
app.listen(4000, () => {
|
||||
console.log('Server Works !!! At port 4000');
|
||||
console.log("Server Works !!! At port 4000");
|
||||
});
|
||||
|
||||
app.get('/downloadmp3', async (req, res, next) => {
|
||||
try {
|
||||
var url = req.query.url;
|
||||
let title = 'audio';
|
||||
await ytdl.getBasicInfo(url, { format: 'mp4' }, (err, info) => {
|
||||
title = info.player_response.videoDetails.title;
|
||||
});
|
||||
app.get("/downloadmp3", async (req, res, next) => {
|
||||
try {
|
||||
var url = req.query.url;
|
||||
let title = "audio";
|
||||
await ytdl.getBasicInfo(url, { format: "mp4" }, (err, info) => {
|
||||
title = info.player_response.videoDetails.title;
|
||||
});
|
||||
|
||||
res.header('Content-Disposition', `attachment; filename='${title}.mp3'`);
|
||||
ytdl(url, {
|
||||
format: 'mp3',
|
||||
filter: 'audioonly',
|
||||
}).pipe(res);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
res.header("Content-Disposition", `attachment; filename="${title}.mp3"`);
|
||||
ytdl(url, {
|
||||
format: "mp3",
|
||||
filter: "audioonly",
|
||||
}).pipe(res);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/downloadmp4', async (req, res, next) => {
|
||||
try {
|
||||
let URL = req.query.url;
|
||||
let title = 'video';
|
||||
app.get("/downloadmp4", async (req, res, next) => {
|
||||
try {
|
||||
let URL = req.query.url;
|
||||
let title = "video";
|
||||
|
||||
await ytdl.getBasicInfo(URL, { format: 'mp4' }, (err, info) => {
|
||||
title = info.player_response.videoDetails.title;
|
||||
});
|
||||
await ytdl.getBasicInfo(URL, { format: "mp4" }, (err, info) => {
|
||||
title = info.player_response.videoDetails.title;
|
||||
});
|
||||
|
||||
res.header('Content-Disposition', `attachment; filename='${title}.mp4'`);
|
||||
ytdl(URL, {
|
||||
format: 'mp4',
|
||||
}).pipe(res);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
res.header("Content-Disposition", `attachment; filename="${title}.mp4"`);
|
||||
ytdl(URL, {
|
||||
format: "mp4",
|
||||
}).pipe(res);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
5702
Server/package-lock.json
generated
5702
Server/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user