|
|
|
@ -117,35 +117,18 @@ async function downloadYtdlp() {
|
|
|
|
|
|
|
|
|
|
|
|
// Downloading appropriate version of yt-dlp
|
|
|
|
// Downloading appropriate version of yt-dlp
|
|
|
|
if (os.platform() == "linux") {
|
|
|
|
if (os.platform() == "linux") {
|
|
|
|
// Checking python version
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const result = cp.execSync("python3 --version", {
|
|
|
|
|
|
|
|
encoding: "utf-8",
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const minorVersion = Number(result.split(" ")[1].split(".")[1]);
|
|
|
|
|
|
|
|
if (minorVersion >= 7) {
|
|
|
|
|
|
|
|
await YTDlpWrap.downloadFromGithub(ytdlpDownloadPath);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Downloading full binary if python version is less than 3.7
|
|
|
|
|
|
|
|
await YTDlpWrap.downloadFromGithub(
|
|
|
|
|
|
|
|
ytdlpDownloadPath,
|
|
|
|
|
|
|
|
"",
|
|
|
|
|
|
|
|
"linux",
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
// Downloading full binary of python3 is not there
|
|
|
|
|
|
|
|
await YTDlpWrap.downloadFromGithub(
|
|
|
|
await YTDlpWrap.downloadFromGithub(
|
|
|
|
ytdlpDownloadPath,
|
|
|
|
ytdlpDownloadPath,
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"linux",
|
|
|
|
"linux",
|
|
|
|
true
|
|
|
|
true
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
localStorage.setItem("fullYtdlpBinPresent", "true");
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// In case of windows/mac
|
|
|
|
// In case of windows/mac
|
|
|
|
await YTDlpWrap.downloadFromGithub(ytdlpDownloadPath);
|
|
|
|
await YTDlpWrap.downloadFromGithub(ytdlpDownloadPath);
|
|
|
|
|
|
|
|
localStorage.setItem("fullYtdlpBinPresent", "true");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getId("popupBox").style.display = "none";
|
|
|
|
getId("popupBox").style.display = "none";
|
|
|
|
@ -157,11 +140,11 @@ async function downloadYtdlp() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Checking if yt-dlp has been installed by user
|
|
|
|
// Checking if yt-dlp has been installed by user
|
|
|
|
cp.exec("yt-dlp --version", (error, stdout, stderr) => {
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
const fullYtdlpBinIsPresent = !!localStorage.getItem("fullYtdlpBinPresent");
|
|
|
|
// Checking if yt-dlp has been installed by program
|
|
|
|
|
|
|
|
cp.exec(`${ytdlpPath} --version`, (error, stdout, stderr) => {
|
|
|
|
cp.exec(`${ytdlpPath} --version`, (error, stdout, stderr) => {
|
|
|
|
if (error) {
|
|
|
|
if (error || !fullYtdlpBinIsPresent) {
|
|
|
|
getId("popupBox").style.display = "block";
|
|
|
|
getId("popupBox").style.display = "block";
|
|
|
|
process.on("uncaughtException", (reason, promise) => {
|
|
|
|
process.on("uncaughtException", (reason, promise) => {
|
|
|
|
document.querySelector("#popupBox p").textContent = i18n.__(
|
|
|
|
document.querySelector("#popupBox p").textContent = i18n.__(
|
|
|
|
@ -178,7 +161,6 @@ cp.exec("yt-dlp --version", (error, stdout, stderr) => {
|
|
|
|
downloadYtdlp();
|
|
|
|
downloadYtdlp();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
downloadYtdlp();
|
|
|
|
downloadYtdlp();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
console.log("yt-dlp binary is present in PATH");
|
|
|
|
console.log("yt-dlp binary is present in PATH");
|
|
|
|
@ -194,34 +176,8 @@ cp.exec("yt-dlp --version", (error, stdout, stderr) => {
|
|
|
|
ipcRenderer.send("ready-for-links");
|
|
|
|
ipcRenderer.send("ready-for-links");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
|
|
|
|
console.log("yt-dlp binary is present in PATH");
|
|
|
|
|
|
|
|
ytDlp = "yt-dlp";
|
|
|
|
|
|
|
|
ytdlp = new YTDlpWrap(ytDlp);
|
|
|
|
|
|
|
|
localStorage.setItem("ytdlp", ytDlp);
|
|
|
|
|
|
|
|
getId("pasteUrl").style.display = "inline-block";
|
|
|
|
|
|
|
|
console.log("yt-dlp bin Path: " + ytDlp);
|
|
|
|
|
|
|
|
ipcRenderer.send("ready-for-links");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check for thumbnail embed support
|
|
|
|
|
|
|
|
let embedThumbnail = false;
|
|
|
|
|
|
|
|
if (os.platform() === "win32" || os.platform() === "darwin"){
|
|
|
|
|
|
|
|
embedThumbnail = true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
cp.execSync("ffprobe -version", {
|
|
|
|
|
|
|
|
encoding: "utf-8",
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log("ffprobe found")
|
|
|
|
|
|
|
|
embedThumbnail = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
let embedThumbnail = true;
|
|
|
|
console.log("ffprobe not found")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function defaultVideoToggle() {
|
|
|
|
function defaultVideoToggle() {
|
|
|
|
let defaultWindow = "video";
|
|
|
|
let defaultWindow = "video";
|
|
|
|
@ -402,7 +358,10 @@ async function getInfo(url) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (format.audio_ext === preferredAudioQuality || format.acodec === preferredAudioQuality){
|
|
|
|
if (
|
|
|
|
|
|
|
|
format.audio_ext === preferredAudioQuality ||
|
|
|
|
|
|
|
|
format.acodec === preferredAudioQuality
|
|
|
|
|
|
|
|
) {
|
|
|
|
preferredAudioFormatLength++;
|
|
|
|
preferredAudioFormatLength++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -423,7 +382,10 @@ async function getInfo(url) {
|
|
|
|
).toFixed(2);
|
|
|
|
).toFixed(2);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (format.tbr) {
|
|
|
|
if (format.tbr) {
|
|
|
|
size = ((format.tbr * 128 * duration) / 1000000).toFixed(2)
|
|
|
|
size = (
|
|
|
|
|
|
|
|
(format.tbr * 128 * duration) /
|
|
|
|
|
|
|
|
1000000
|
|
|
|
|
|
|
|
).toFixed(2);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
size = i18n.__("Unknown size");
|
|
|
|
size = i18n.__("Unknown size");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -511,9 +473,15 @@ async function getInfo(url) {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
audio_ext = format.audio_ext;
|
|
|
|
audio_ext = format.audio_ext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (format.audio_ext === preferredAudioQuality || format.acodec === preferredAudioQuality) {
|
|
|
|
if (
|
|
|
|
|
|
|
|
format.audio_ext === preferredAudioQuality ||
|
|
|
|
|
|
|
|
format.acodec === preferredAudioQuality
|
|
|
|
|
|
|
|
) {
|
|
|
|
preferredAudioFormatCount += 1;
|
|
|
|
preferredAudioFormatCount += 1;
|
|
|
|
if (preferredAudioFormatCount === preferredAudioFormatLength){
|
|
|
|
if (
|
|
|
|
|
|
|
|
preferredAudioFormatCount ===
|
|
|
|
|
|
|
|
preferredAudioFormatLength
|
|
|
|
|
|
|
|
) {
|
|
|
|
audioSelectedText = " selected ";
|
|
|
|
audioSelectedText = " selected ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1004,7 +972,10 @@ function download(
|
|
|
|
ffmpeg,
|
|
|
|
ffmpeg,
|
|
|
|
"--no-playlist",
|
|
|
|
"--no-playlist",
|
|
|
|
"--embed-metadata",
|
|
|
|
"--embed-metadata",
|
|
|
|
(extractFormat1 == "m4a" || embedThumbnail) && extractFormat1 == "mp3" ? "--embed-thumbnail": "",
|
|
|
|
(extractFormat1 == "m4a" || embedThumbnail) &&
|
|
|
|
|
|
|
|
extractFormat1 == "mp3"
|
|
|
|
|
|
|
|
? "--embed-thumbnail"
|
|
|
|
|
|
|
|
: "",
|
|
|
|
cookieArg,
|
|
|
|
cookieArg,
|
|
|
|
browser,
|
|
|
|
browser,
|
|
|
|
configArg,
|
|
|
|
configArg,
|
|
|
|
@ -1034,7 +1005,9 @@ function download(
|
|
|
|
subs2 || subLangs,
|
|
|
|
subs2 || subLangs,
|
|
|
|
"--no-playlist",
|
|
|
|
"--no-playlist",
|
|
|
|
"--embed-metadata",
|
|
|
|
"--embed-metadata",
|
|
|
|
(ext == "m4a" || ext == "mp4") && embedThumbnail ? "--embed-thumbnail": "",
|
|
|
|
(ext == "m4a" || ext == "mp4") && embedThumbnail
|
|
|
|
|
|
|
|
? "--embed-thumbnail"
|
|
|
|
|
|
|
|
: "",
|
|
|
|
cookieArg,
|
|
|
|
cookieArg,
|
|
|
|
browser,
|
|
|
|
browser,
|
|
|
|
configArg,
|
|
|
|
configArg,
|
|
|
|
|