83 lines
2.5 KiB
HTML
83 lines
2.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>YouTube Video Downloader</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
text-align: center;
|
|
}
|
|
.container {
|
|
margin-top: 50px;
|
|
}
|
|
input[type="url"], select {
|
|
width: 80%;
|
|
padding: 10px;
|
|
margin: 10px 0;
|
|
}
|
|
select {
|
|
width: auto;
|
|
}
|
|
button {
|
|
padding: 10px 20px;
|
|
background-color: #ff0000;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
}
|
|
button:hover {
|
|
background-color: #cc0000;
|
|
}
|
|
#status {
|
|
margin-top: 20px;
|
|
color: #666;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>YouTube Video Downloader</h1>
|
|
<form id="downloadForm">
|
|
<input type="url" id="videoUrl" placeholder="Enter YouTube URL" required>
|
|
<select id="downloadType">
|
|
<option value="video">Video</option>
|
|
<option value="audio">Audio (MP3)</option>
|
|
</select>
|
|
<button type="submit">Download</button>
|
|
</form>
|
|
<div id="status"></div>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById('downloadForm').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
const url = document.getElementById('videoUrl').value;
|
|
const downloadType = document.getElementById('downloadType').value;
|
|
const status = document.getElementById('status');
|
|
|
|
status.textContent = 'Starting download...';
|
|
|
|
fetch(`http://localhost:5000/download?url=${encodeURIComponent(url)}&type=${downloadType}`)
|
|
.then(response => {
|
|
if (!response.ok) {
|
|
return response.text().then(text => {
|
|
throw new Error(text || 'Download failed');
|
|
});
|
|
}
|
|
status.textContent = 'Download completed!';
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
status.textContent = 'Error: ' + error.message;
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|