This commit is contained in:
2022-05-29 19:08:21 +02:00
committed by GitHub
parent 31f007c250
commit 0d70e3796f

View File

@@ -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);