|
|
|
|
@ -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 =
|
|
|
|
|
"<option value='" +
|
|
|
|
|
@ -548,8 +552,7 @@ async function getInfo(url) {
|
|
|
|
|
quality +
|
|
|
|
|
spaceAfterQuality +
|
|
|
|
|
"| " +
|
|
|
|
|
extension +
|
|
|
|
|
spaceAfterExtension +
|
|
|
|
|
extension.padEnd(5, "\xa0") +
|
|
|
|
|
"| " +
|
|
|
|
|
vcodec +
|
|
|
|
|
spaceAfterVcodec +
|
|
|
|
|
@ -588,18 +591,23 @@ async function getInfo(url) {
|
|
|
|
|
|
|
|
|
|
const format_id = format.format_id + "|" + audio_ext;
|
|
|
|
|
|
|
|
|
|
/**@type {string} */
|
|
|
|
|
let formatNote = (i18n.__(format.format_note) ||
|
|
|
|
|
i18n.__("Unknown quality"));
|
|
|
|
|
|
|
|
|
|
formatNote = formatNote.padEnd(maxAudioFormatNoteLength, "\xa0")
|
|
|
|
|
|
|
|
|
|
const element =
|
|
|
|
|
"<option value='" +
|
|
|
|
|
format_id +
|
|
|
|
|
"'" +
|
|
|
|
|
audioSelectedText +
|
|
|
|
|
">" +
|
|
|
|
|
i18n.__("Quality") +
|
|
|
|
|
": " +
|
|
|
|
|
(i18n.__(format.format_note) ||
|
|
|
|
|
i18n.__("Unknown quality")) +
|
|
|
|
|
" | " +
|
|
|
|
|
audio_ext +
|
|
|
|
|
// i18n.__("Quality") +
|
|
|
|
|
// ": " +
|
|
|
|
|
formatNote +
|
|
|
|
|
"| " +
|
|
|
|
|
audio_ext.padEnd(4, "\xa0") +
|
|
|
|
|
" | " +
|
|
|
|
|
size +
|
|
|
|
|
"</option>";
|
|
|
|
|
@ -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 = `
|
|
|
|
|
<div class="item" id="${randomId}">
|
|
|
|
|
@ -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,
|
|
|
|
|
|