Embed thumbnail and Fix Unknown size

pull/171/head
Andrew 2 years ago
parent 099f9514aa
commit 7bf1f2e1e1

@ -4,7 +4,7 @@
"yt-dlp-wrap-plus": "^2.3.16"
},
"name": "ytdownloader",
"version": "3.14.3",
"version": "3.15.0-beta",
"main": "main.js",
"scripts": {
"start": "electron .",

@ -44,6 +44,24 @@ if (!fs.existsSync(ffmpegPath)) {
}
console.log("ffmpeg:", ffmpeg);
// 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) {
console.log("ffprobe not found")
}
}
let foldernameFormat = "%(playlist_title)s";
let filenameFormat = "%(playlist_index)s.%(title)s.%(ext)s";
let playlistIndex = 1;
@ -147,7 +165,7 @@ function download(type) {
configArg,
configTxt,
"--embed-metadata",
// videoType == "mp4" ? "--embed-thumbnail": "",
videoType == "mp4" && embedThumbnail ? "--embed-thumbnail": "",
`"${url}"`,
],
{shell: true, detached: false},
@ -180,7 +198,7 @@ function download(type) {
configArg,
configTxt,
"--embed-metadata",
// "--embed-thumbnail",
embedThumbnail ? "--embed-thumbnail": "",
`"${url}"`,
],
{shell: true, detached: false},

@ -205,6 +205,24 @@ cp.exec("yt-dlp --version", (error, stdout, stderr) => {
}
});
// 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) {
console.log("ffprobe not found")
}
}
function defaultVideoToggle() {
let defaultWindow = "video";
if (localStorage.getItem("defaultWindow")) {
@ -404,7 +422,11 @@ async function getInfo(url) {
1000000
).toFixed(2);
} else {
size = i18n.__("Unknown size");
if (format.tbr) {
size = ((format.tbr * 128 * duration) / 1000000).toFixed(2)
} else {
size = i18n.__("Unknown size");
}
}
// For videos
@ -415,7 +437,7 @@ async function getInfo(url) {
) {
if (size !== "Unknown size") {
size = (Number(size) + 0 || Number(audioSize)).toFixed(
2
1
);
size = size + " " + i18n.__("MB");
}
@ -944,7 +966,7 @@ function download(
subs2 || subLangs,
"--no-playlist",
"--embed-metadata",
// ext == "mp4" ? "--embed-thumbnail": "",
ext == "mp4" && embedThumbnail ? "--embed-thumbnail": "",
configArg,
configTxt,
cookieArg,
@ -982,7 +1004,7 @@ function download(
ffmpeg,
"--no-playlist",
"--embed-metadata",
// extractFormat1 == "m4a" || extractFormat1 == "mp3" ? "--embed-thumbnail": "",
(extractFormat1 == "m4a" || embedThumbnail) && extractFormat1 == "mp3" ? "--embed-thumbnail": "",
cookieArg,
browser,
configArg,
@ -1012,7 +1034,7 @@ function download(
subs2 || subLangs,
"--no-playlist",
"--embed-metadata",
// ext == "m4a" || ext == "mp4" ? "--embed-thumbnail": "",
(ext == "m4a" || ext == "mp4") && embedThumbnail ? "--embed-thumbnail": "",
cookieArg,
browser,
configArg,

Loading…
Cancel
Save