Files
archived-youtubeDownloader/script.js
balajinikhil 4fe525ff3c fix
2020-04-13 19:05:14 +05:30

25 lines
681 B
JavaScript

let Btn = document.getElementById('mp4');
let URLinput = document.querySelector('.URL-input');
let select = document.querySelector('.opt');
let serverURL = 'http://localhost:4000';
Btn.addEventListener('click', () => {
if (!URLinput.value) {
alert('Enter YouTube URL');
} else {
if (select.value == 'mp3') {
redirectMp3(URLinput.value);
} else if (select.value == 'mp4') {
redirectMp4(URLinput.value);
}
}
});
function redirectMp3(query) {
window.location.href = `${serverURL}/downloadmp3?url=${query}`;
}
function redirectMp4(query) {
window.location.href = `${serverURL}/downloadmp4?url=${query}`;
}