Moorad / youtube-video-downloader

199 stars 138 forks source link

when i hit convert mp4 button it keeps waiting for localhost. #20

Closed aizazhussain341 closed 4 years ago

aizazhussain341 commented 4 years ago

here is my script.js `var mp3Btn = document.getElementById('mp3'); var mp4Btn = document.getElementById('mp4'); var URLinput = document.querySelector('.URL-input'); var server = 'http://localhost:8000';

mp3Btn.addEventListener('click', () => { console.log(URL: ${URLinput.value});
redirectMp3(URLinput.value); });

mp4Btn.addEventListener('click', () => { console.log(URL: ${URLinput.value});
redirectMp4(URLinput.value); });

function redirectMp3(query) { window.location.href = ${server}/downloadmp3?url=${query}; }

function redirectMp4(query) { window.location.href = ${server}/downloadmp4?url=${query}; }`

aizazhussain341 commented 4 years ago

heres server.js const express = require('express'); const cors = require('cors'); const ytdl = require('ytdl-core');

const app = express();

//app.use(cors());

app.listen(8000, () => { console.log('Server Works !!! At port 8000'); });

app.get('/downloadmp3', (req,res) => { var url = req.query.url; res.header('Content-Disposition', 'attachment; filename="audio.mp3"'); ytdl(url, { format: 'mp3', filter: 'audioonly' }).pipe(res); });

app.get('/downloadmp4', (req,res) => { var url = req.query.url; res.header('Content-Disposition', 'attachment; filename="video.mp4"'); ytdl(url, { format: 'mp4' }).pipe(res); }); `

Moorad commented 4 years ago

Does the server run correctly when you use node index.js?

aizazhussain341 commented 4 years ago

thanks for replying but the issue was resolved it was internet issue. when internet got stable the issue was resolved <3

Moorad commented 4 years ago

Sorry for the very late reply

aizazhussain341 commented 4 years ago

No worries. Thanks