diff --git a/assets/css/index.css b/assets/css/index.css
index ba95d8c..e454072 100644
--- a/assets/css/index.css
+++ b/assets/css/index.css
@@ -402,7 +402,7 @@ body {
max-width: 100%;
}
-#videoFormatSelect, #audioFormatSelect {
+#videoFormatSelect, #audioFormatSelect, #audioForVideoFormatSelect {
font-family: JetBrains, monospace;
font-size: medium;
}
diff --git a/html/index.html b/html/index.html
index d4feee9..92ffb69 100644
--- a/html/index.html
+++ b/html/index.html
@@ -131,34 +131,8 @@
-
-
-
-
-
+
Close app when download finishes
@@ -192,6 +166,32 @@
+
+
+
+
diff --git a/src/index.js b/src/index.js
index b8aedaa..5fc794d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -23,6 +23,7 @@ function selectVideo(){
videoToggle.style.backgroundColor = "var(--box-toggleOn)";
audioToggle.style.backgroundColor = "var(--box-toggle)";
getId("audioList").style.display = "none";
+ getId("audioExtract").style.display = "none";
getId("videoList").style.display = "block";
}
@@ -32,4 +33,5 @@ function selectAudio(){
videoToggle.style.backgroundColor = "var(--box-toggle)";
getId("videoList").style.display = "none";
getId("audioList").style.display = "block";
+ getId("audioExtract").style.display = "block";
}
\ No newline at end of file
diff --git a/src/renderer.js b/src/renderer.js
index caf3e4d..952620a 100644
--- a/src/renderer.js
+++ b/src/renderer.js
@@ -382,6 +382,7 @@ async function getInfo(url) {
let preferredAudioFormatLength = 0;
let preferredAudioFormatCount = 0;
+ let maxAudioFormatNoteLength = 10;
// Initially going through all formats
// Getting approx size of audio file and checking if audio is present
@@ -420,9 +421,14 @@ async function getInfo(url) {
audioSize =
Number(format.filesize || format.filesize_approx) /
1000000;
+
if (!audioExtensionList.includes(format.audio_ext)) {
audioExtensionList.push(format.audio_ext);
}
+
+ if (format.format_note.length > maxAudioFormatNoteLength) {
+ maxAudioFormatNoteLength = format.format_note.length
+ }
}
if (
@@ -528,16 +534,14 @@ async function getInfo(url) {
format.format_id ||
"Unknown quality";
const spaceAfterQuality = " ".repeat(
- quality.length > 8 && 8 - quality.length > 0
+ quality.length <= 8 && 8 - quality.length > 0
? 8 - quality.length
- : quality.length + 2
+ : quality.length + 1
);
// Extension
const extension = format.ext;
- const spaceAfterExtension = " ".repeat(
- 5 - extension.length
- );
+
// Format and Quality Options
const element =
"";
@@ -897,9 +905,10 @@ function download(
const url = url1 || getId("url").value;
console.log("URL", url);
- let ext, extractExt, extractFormat1, extractQuality1;
+ let ext, extractExt, extractFormat1, extractQuality1, audioForVideoExt;
- let format_id;
+ /**@type {string}*/
+ let format_id, audioForVideoFormat_id;
const randomId = "a" + Math.random().toFixed(10).toString().slice(2);
// Whether to close app
@@ -907,11 +916,31 @@ function download(
if (type === "video") {
const videoValue = getId("videoFormatSelect").value;
+ /**@type {string} */
+ const audioForVideoValue = getId("audioForVideoFormatSelect").value
+
format_id = videoValue.split("|")[0];
- ext = videoValue.split("|")[1];
+ const videoExt = videoValue.split("|")[1];
+
if (videoValue.split("|")[2] != "NO") {
preferredVideoQuality = Number(videoValue.split("|")[2]);
}
+
+ audioForVideoFormat_id = audioForVideoValue.split("|")[0];
+
+ if (audioForVideoValue.split("|")[1] === "webm") {
+ audioForVideoExt = "opus";
+ } else {
+ audioForVideoExt = audioForVideoValue.split("|")[1];
+ }
+
+ if ((videoExt === "mp4" && audioForVideoExt === "opus") || (videoExt === "webm" && audioForVideoExt === "m4a")) {
+ ext = "mkv"
+ } else {
+ ext = videoExt;
+ }
+
+
} else if (type === "audio") {
format_id = getId("audioFormatSelect").value.split("|")[0];
if (getId("audioFormatSelect").value.split("|")[1] === "webm") {
@@ -920,7 +949,7 @@ function download(
ext = getId("audioFormatSelect").value.split("|")[1];
}
}
- console.log("video extension:", ext);
+ console.log("Download extension:", ext);
const newItem = `
@@ -995,20 +1024,26 @@ function download(
}
console.log("Filename:", filename);
+ /**@type {string} */
let audioFormat;
- if (ext === "mp4") {
- if (!(audioExtensionList.length == 0)) {
- if (audioExtensionList.includes("m4a")) {
- audioFormat = "+m4a";
+ if (audioForVideoFormat_id === "auto") {
+ if (ext === "mp4") {
+ if (!(audioExtensionList.length == 0)) {
+ if (audioExtensionList.includes("m4a")) {
+ audioFormat = "+m4a";
+ } else {
+ audioFormat = "+ba";
+ }
} else {
- audioFormat = "+ba";
+ audioFormat = "";
}
} else {
- audioFormat = "";
+ audioFormat = "+ba";
}
+
} else {
- audioFormat = "+ba";
+ audioFormat = `+${audioForVideoFormat_id}`;
}
const controller = new AbortController();
@@ -1035,7 +1070,7 @@ function download(
subs2 || subLangs,
"--no-playlist",
"--embed-metadata",
- ext == "mp4" ? "--embed-thumbnail" : "",
+ ext == "mp4" && audioForVideoExt === "m4a" ? "--embed-thumbnail" : "",
configArg,
configTxt,
cookieArg,