|
6 | 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
7 | 7 | <title>VideoSnatcher</title> |
8 | 8 | <style> |
9 | | - button :disabled { |
10 | | - background-color: #ccc; |
11 | | - cursor: not-allowed; |
| 9 | + button:disabled { |
| 10 | + background-color: #ccc !important; |
| 11 | + cursor: not-allowed !important; |
12 | 12 | } |
| 13 | + |
| 14 | + button:disabled:hover { |
| 15 | + background-color: #ccc !important; |
| 16 | + cursor: not-allowed !important; |
| 17 | + } |
| 18 | + |
13 | 19 | /* Loader styles remain unchanged */ |
14 | 20 | .loader { |
15 | 21 | --s: 20px; |
|
232 | 238 | .then(response => { |
233 | 239 | if (response.status === 200) { |
234 | 240 | response.json().then(data => { |
235 | | - const a = document.createElement('a'); |
236 | | - a.href = `http://localhost:${getParam("port")}/get_vid?path=${encodeURIComponent(data.path)}`; |
237 | | - if (data.path) { |
238 | | - a.download = data.path.split('/').pop(); |
| 241 | + let outputFormat; |
| 242 | + if (format.includes('vid') && format.includes('aud')) { |
| 243 | + const [videoForm, audioForm] = format |
| 244 | + .split(',') |
| 245 | + .map(part => part.split(':')[1].trim()); |
| 246 | + outputFormat = videoForm; |
239 | 247 | } else { |
240 | | - alert("Download path is undefined. Please try again."); |
241 | | - document.querySelectorAll("button").forEach(button => { |
242 | | - button.disabled = false; |
243 | | - }); |
244 | | - document.getElementById("downloader_loader").style.display = "none"; |
245 | | - return; |
| 248 | + outputFormat = format; |
246 | 249 | } |
247 | | - document.body.appendChild(a); |
248 | | - a.click(); |
249 | | - document.body.removeChild(a); |
250 | | - document.querySelectorAll("button").forEach(button => { |
251 | | - button.disabled = false; |
252 | | - }); |
253 | | - document.getElementById("downloader_loader").style.display = "none"; |
| 250 | + const a = document.createElement('a'); |
| 251 | + fetch(`http://localhost:${getParam("port")}/get_vid?path=${encodeURIComponent(data.path)}`) |
| 252 | + .then(response => response.blob()) |
| 253 | + .then(blob => { |
| 254 | + const blobUrl = URL.createObjectURL(blob); |
| 255 | + a.href = blobUrl; |
| 256 | + console.log(outputFormat) |
| 257 | + a.download = `download.${outputFormat}`; |
| 258 | + a.click(); |
| 259 | + document.querySelectorAll("button").forEach(button => { |
| 260 | + button.disabled = false; |
| 261 | + }); |
| 262 | + document.getElementById("downloader_loader").style.display = "none"; |
| 263 | + }); |
254 | 264 | }); |
255 | 265 | } else { |
256 | 266 | response.text().then(text => { |
|
292 | 302 | const result = {}; |
293 | 303 | result.id = arr[0]; |
294 | 304 | result.url = url; |
295 | | - console.log(pass) |
296 | 305 | if (pass) { |
297 | 306 | result.pass = pass; |
298 | 307 | } |
|
0 commit comments