mirror of
https://github.com/SrIzan10/youtubeDownloader.git
synced 2026-05-01 11:06:58 +00:00
24 lines
623 B
JavaScript
24 lines
623 B
JavaScript
let Btn = document.getElementById('btn');
|
|
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}`;
|
|
} |