Update templates/index.html
Browse files- templates/index.html +120 -45
templates/index.html
CHANGED
@@ -6,65 +6,119 @@
|
|
6 |
<title>YouTube Audio Downloader</title>
|
7 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
8 |
<script src="https://cdn.tailwindcss.com"></script>
|
|
|
|
|
9 |
</head>
|
10 |
-
<body class="bg-gray-100 min-h-screen">
|
11 |
-
<div class="container mx-auto px-4 py-
|
12 |
<div class="max-w-2xl mx-auto">
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
<!-- Input Form -->
|
16 |
-
<div class="bg-white
|
17 |
-
<div class="mb-
|
18 |
-
<
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
</div>
|
21 |
<button onclick="getVideoInfo()"
|
22 |
-
class="w-full bg-blue-500 text-white py-
|
|
|
23 |
Get Video Info
|
24 |
</button>
|
25 |
</div>
|
26 |
|
27 |
<!-- Video Info Section -->
|
28 |
-
<div id="videoInfo" class="hidden
|
29 |
-
<div
|
30 |
-
<div id="
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
<
|
|
|
|
|
|
|
|
|
45 |
</div>
|
46 |
</div>
|
47 |
-
|
48 |
-
<!-- Error Message -->
|
49 |
-
<div id="errorMessage" class="hidden bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4">
|
50 |
-
</div>
|
51 |
</div>
|
52 |
</div>
|
53 |
|
54 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
function showLoading() {
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
|
59 |
-
function
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
function showError(message) {
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
|
70 |
function formatDuration(seconds) {
|
@@ -90,17 +144,19 @@
|
|
90 |
data: JSON.stringify({ url: url }),
|
91 |
success: function(response) {
|
92 |
$('#thumbnailContainer').html(`
|
93 |
-
<img src="${response.thumbnail}" alt="Video thumbnail"
|
|
|
94 |
`);
|
95 |
$('#videoTitle').text(response.title);
|
96 |
-
$('#channelName').text(`Channel: ${response.channel}`);
|
97 |
-
$('#duration').text(`Duration: ${formatDuration(response.duration)}`);
|
98 |
$('#videoInfo').removeClass('hidden');
|
99 |
-
|
|
|
100 |
},
|
101 |
error: function(xhr) {
|
|
|
102 |
showError(xhr.responseJSON?.error || 'Failed to get video information');
|
103 |
-
hideLoading();
|
104 |
}
|
105 |
});
|
106 |
}
|
@@ -112,7 +168,16 @@
|
|
112 |
return;
|
113 |
}
|
114 |
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
$.ajax({
|
118 |
url: '/download',
|
@@ -132,14 +197,24 @@
|
|
132 |
document.body.appendChild(a);
|
133 |
a.click();
|
134 |
window.URL.revokeObjectURL(downloadUrl);
|
135 |
-
|
|
|
136 |
},
|
137 |
error: function(xhr) {
|
|
|
138 |
showError('Failed to download audio');
|
139 |
-
hideLoading();
|
140 |
}
|
141 |
});
|
142 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
</script>
|
144 |
</body>
|
145 |
</html>
|
|
|
6 |
<title>YouTube Audio Downloader</title>
|
7 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
8 |
<script src="https://cdn.tailwindcss.com"></script>
|
9 |
+
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
10 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
11 |
</head>
|
12 |
+
<body class="bg-gradient-to-br from-gray-50 to-gray-100 min-h-screen">
|
13 |
+
<div class="container mx-auto px-4 py-12">
|
14 |
<div class="max-w-2xl mx-auto">
|
15 |
+
<!-- Header with animation -->
|
16 |
+
<div class="text-center mb-12 animate-fade-in">
|
17 |
+
<div class="flex items-center justify-center mb-4">
|
18 |
+
<i class="fab fa-youtube text-red-500 text-5xl mr-3 animate-bounce"></i>
|
19 |
+
<h1 class="text-4xl font-bold bg-gradient-to-r from-gray-800 to-gray-600 bg-clip-text text-transparent">
|
20 |
+
YouTube Audio Downloader
|
21 |
+
</h1>
|
22 |
+
</div>
|
23 |
+
<p class="text-gray-600 text-lg">Convert and download your favorite YouTube videos as MP3</p>
|
24 |
+
</div>
|
25 |
|
26 |
+
<!-- Input Form with glassmorphism effect -->
|
27 |
+
<div class="bg-white bg-opacity-80 backdrop-blur-lg rounded-xl shadow-lg p-8 mb-8 transform transition-all duration-300 hover:shadow-xl border border-gray-100">
|
28 |
+
<div class="relative mb-6">
|
29 |
+
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
30 |
+
<i class="fas fa-link text-blue-500"></i>
|
31 |
+
</div>
|
32 |
+
<input type="text" id="youtubeUrl"
|
33 |
+
placeholder="Paste YouTube URL here"
|
34 |
+
class="w-full pl-10 pr-4 py-4 border-2 border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all text-gray-700 bg-white bg-opacity-90">
|
35 |
</div>
|
36 |
<button onclick="getVideoInfo()"
|
37 |
+
class="w-full bg-gradient-to-r from-blue-500 to-blue-600 text-white py-4 px-6 rounded-lg hover:from-blue-600 hover:to-blue-700 transition-all transform hover:scale-[1.02] flex items-center justify-center font-semibold">
|
38 |
+
<i class="fas fa-search mr-2"></i>
|
39 |
Get Video Info
|
40 |
</button>
|
41 |
</div>
|
42 |
|
43 |
<!-- Video Info Section -->
|
44 |
+
<div id="videoInfo" class="hidden animate-fade-in">
|
45 |
+
<div class="bg-white bg-opacity-80 backdrop-blur-lg rounded-xl shadow-lg p-8 mb-8 transform transition-all duration-300 hover:shadow-xl border border-gray-100">
|
46 |
+
<div id="videoDetails" class="mb-6">
|
47 |
+
<div id="thumbnailContainer" class="mb-6 rounded-xl overflow-hidden shadow-md transform transition-all duration-300 hover:shadow-xl"></div>
|
48 |
+
<h2 id="videoTitle" class="text-2xl font-semibold mb-4 text-gray-800"></h2>
|
49 |
+
<div class="space-y-3">
|
50 |
+
<p id="channelName" class="text-gray-600 flex items-center bg-gray-50 p-3 rounded-lg">
|
51 |
+
<i class="fas fa-user-circle text-blue-500 mr-2"></i>
|
52 |
+
<span></span>
|
53 |
+
</p>
|
54 |
+
<p id="duration" class="text-gray-600 flex items-center bg-gray-50 p-3 rounded-lg">
|
55 |
+
<i class="fas fa-clock text-blue-500 mr-2"></i>
|
56 |
+
<span></span>
|
57 |
+
</p>
|
58 |
+
</div>
|
59 |
+
</div>
|
60 |
+
<button onclick="downloadAudio()"
|
61 |
+
class="w-full bg-gradient-to-r from-green-500 to-green-600 text-white py-4 px-6 rounded-lg hover:from-green-600 hover:to-green-700 transition-all transform hover:scale-[1.02] flex items-center justify-center font-semibold">
|
62 |
+
<i class="fas fa-download mr-2"></i>
|
63 |
+
Download Audio
|
64 |
+
</button>
|
65 |
</div>
|
66 |
</div>
|
|
|
|
|
|
|
|
|
67 |
</div>
|
68 |
</div>
|
69 |
|
70 |
<script>
|
71 |
+
// Add custom styles for animations
|
72 |
+
const style = document.createElement('style');
|
73 |
+
style.textContent = `
|
74 |
+
@keyframes fade-in {
|
75 |
+
from { opacity: 0; transform: translateY(20px); }
|
76 |
+
to { opacity: 1; transform: translateY(0); }
|
77 |
+
}
|
78 |
+
.animate-fade-in {
|
79 |
+
animation: fade-in 0.6s ease-out;
|
80 |
+
}
|
81 |
+
`;
|
82 |
+
document.head.appendChild(style);
|
83 |
+
|
84 |
function showLoading() {
|
85 |
+
Swal.fire({
|
86 |
+
title: 'Processing...',
|
87 |
+
html: 'Please wait while we fetch the video information',
|
88 |
+
timerProgressBar: true,
|
89 |
+
showConfirmButton: false,
|
90 |
+
allowOutsideClick: false,
|
91 |
+
didOpen: () => {
|
92 |
+
Swal.showLoading();
|
93 |
+
}
|
94 |
+
});
|
95 |
}
|
96 |
|
97 |
+
function showSuccess(message) {
|
98 |
+
Swal.fire({
|
99 |
+
icon: 'success',
|
100 |
+
title: 'Success!',
|
101 |
+
text: message,
|
102 |
+
showConfirmButton: false,
|
103 |
+
timer: 2000,
|
104 |
+
position: 'top-end',
|
105 |
+
toast: true,
|
106 |
+
background: '#F0FDF4',
|
107 |
+
iconColor: '#22C55E'
|
108 |
+
});
|
109 |
}
|
110 |
|
111 |
function showError(message) {
|
112 |
+
Swal.fire({
|
113 |
+
icon: 'error',
|
114 |
+
title: 'Oops...',
|
115 |
+
text: message,
|
116 |
+
showConfirmButton: true,
|
117 |
+
position: 'top-end',
|
118 |
+
toast: true,
|
119 |
+
background: '#FEF2F2',
|
120 |
+
iconColor: '#EF4444'
|
121 |
+
});
|
122 |
}
|
123 |
|
124 |
function formatDuration(seconds) {
|
|
|
144 |
data: JSON.stringify({ url: url }),
|
145 |
success: function(response) {
|
146 |
$('#thumbnailContainer').html(`
|
147 |
+
<img src="${response.thumbnail}" alt="Video thumbnail"
|
148 |
+
class="w-full rounded-lg transform transition-all duration-300 hover:scale-[1.02]">
|
149 |
`);
|
150 |
$('#videoTitle').text(response.title);
|
151 |
+
$('#channelName span').text(`Channel: ${response.channel}`);
|
152 |
+
$('#duration span').text(`Duration: ${formatDuration(response.duration)}`);
|
153 |
$('#videoInfo').removeClass('hidden');
|
154 |
+
Swal.close();
|
155 |
+
showSuccess('Video information retrieved successfully');
|
156 |
},
|
157 |
error: function(xhr) {
|
158 |
+
Swal.close();
|
159 |
showError(xhr.responseJSON?.error || 'Failed to get video information');
|
|
|
160 |
}
|
161 |
});
|
162 |
}
|
|
|
168 |
return;
|
169 |
}
|
170 |
|
171 |
+
Swal.fire({
|
172 |
+
title: 'Starting Download',
|
173 |
+
html: 'Preparing your audio file...',
|
174 |
+
timerProgressBar: true,
|
175 |
+
showConfirmButton: false,
|
176 |
+
allowOutsideClick: false,
|
177 |
+
didOpen: () => {
|
178 |
+
Swal.showLoading();
|
179 |
+
}
|
180 |
+
});
|
181 |
|
182 |
$.ajax({
|
183 |
url: '/download',
|
|
|
197 |
document.body.appendChild(a);
|
198 |
a.click();
|
199 |
window.URL.revokeObjectURL(downloadUrl);
|
200 |
+
Swal.close();
|
201 |
+
showSuccess('Download started successfully');
|
202 |
},
|
203 |
error: function(xhr) {
|
204 |
+
Swal.close();
|
205 |
showError('Failed to download audio');
|
|
|
206 |
}
|
207 |
});
|
208 |
}
|
209 |
+
|
210 |
+
// Add nice entrance animation when page loads
|
211 |
+
document.addEventListener('DOMContentLoaded', function() {
|
212 |
+
document.body.style.opacity = '0';
|
213 |
+
setTimeout(() => {
|
214 |
+
document.body.style.transition = 'opacity 0.5s ease-in';
|
215 |
+
document.body.style.opacity = '1';
|
216 |
+
}, 100);
|
217 |
+
});
|
218 |
</script>
|
219 |
</body>
|
220 |
</html>
|