Skip to content

Commit d49e1c0

Browse files
committed
last minute changes
1 parent 4469ddd commit d49e1c0

File tree

2 files changed

+33
-22
lines changed

2 files changed

+33
-22
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,9 @@ expressApp.get('/get_vid', (req, res) => {
388388
res.setHeader('Content-Type', 'video/webm');
389389
}
390390
} else if (ext === '.mp3') {
391-
res.setHeader('Content-Type', 'audio/mpeg');
391+
res.setHeader('Content-Type', 'audio/mp3');
392+
} else if (ext === '.m4a') {
393+
res.setHeader('Content-Type', 'audio/m4a');
392394
} else {
393395
res.setHeader('Content-Type', 'application/octet-stream');
394396
}

web/index.html

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>VideoSnatcher</title>
88
<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;
1212
}
13+
14+
button:disabled:hover {
15+
background-color: #ccc !important;
16+
cursor: not-allowed !important;
17+
}
18+
1319
/* Loader styles remain unchanged */
1420
.loader {
1521
--s: 20px;
@@ -232,25 +238,29 @@
232238
.then(response => {
233239
if (response.status === 200) {
234240
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;
239247
} 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;
246249
}
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+
});
254264
});
255265
} else {
256266
response.text().then(text => {
@@ -292,7 +302,6 @@
292302
const result = {};
293303
result.id = arr[0];
294304
result.url = url;
295-
console.log(pass)
296305
if (pass) {
297306
result.pass = pass;
298307
}

0 commit comments

Comments
 (0)