Translations, Vcodec, More formats option

pull/181/head
Andrew 2 years ago
parent bfdfba0925
commit 26d5fc4171

@ -129,6 +129,7 @@ Translations into other languages would be highly appreciated. If you want to he
| Greek | ✔️ |
| Hungarian | ✔️ |
| Italian | ✔️ |
| Japanese | ✔️ |
| Persian | ✔️ |
| Polish | ✔️ |
| Portuguese (Brazil) | ✔️ |
@ -138,7 +139,7 @@ Translations into other languages would be highly appreciated. If you want to he
| Ukrainian | ✔️ |
| Vietnamese | ✔️ |
Thanks to [nxjosephofficial](https://github.com/nxjosephofficial), [LINUX-SAUNA](https://t.me/linuxsauna), [Proxycon](https://github.com/proxycon), [albanobattistella](https://github.com/albanobattistella), [TheBlueQuasar](https://github.com/TheBlueQuasar), [MrQuerter](https://github.com/MrQuerter), [KotoWhiskas](https://github.com/KotoWhiskas), [André](https://github.com/andre1828), [haggen88](https://github.com/haggen88), [XfedeX](https://github.com/XfedeX), [Jok3r](https://github.com/th3knv), [TitouanReal](https://github.com/TitouanReal), [soredake](https://github.com/soredake), [yoi](https://github.com/thiennguyenqn), [HowlingWerewolf](https://github.com/HowlingWerewolf) and others for helping.
Thanks to [nxjosephofficial](https://github.com/nxjosephofficial), [LINUX-SAUNA](https://t.me/linuxsauna), [Proxycon](https://github.com/proxycon), [albanobattistella](https://github.com/albanobattistella), [TheBlueQuasar](https://github.com/TheBlueQuasar), [MrQuerter](https://github.com/MrQuerter), [KotoWhiskas](https://github.com/KotoWhiskas), [André](https://github.com/andre1828), [haggen88](https://github.com/haggen88), [XfedeX](https://github.com/XfedeX), [Jok3r](https://github.com/th3knv), [TitouanReal](https://github.com/TitouanReal), [soredake](https://github.com/soredake), [yoi](https://github.com/thiennguyenqn), [HowlingWerewolf](https://github.com/HowlingWerewolf), [Kum](https://github.com/kum4423) and others for helping.
## Used technologies

@ -401,7 +401,7 @@ body {
outline: none;
}
#videoFormatSelect {
#videoFormatSelect, #audioFormatSelect {
font-family: JetBrains, monospace;
font-size: medium;
}

@ -39,18 +39,18 @@
<br>
<!-- Language -->
<!-- Language -->
<div class="prefBox">
<label id="selectLn">Select Language (Requires reload)</label>
<select id="select" onchange="changeLanguage()">
<option value="en">English</option>
<option value="de">Deutsch</option>
<option value="es">Español</option>
<option value="fa">فارسی</option>
<option value="el">Ελληνικά</option>
<option value="fr">Français</option>
<option value="it">Italiano</option>
<option value="ja">Japanese</option>
<option value="hu">Magyar</option>
<option value="pl">Polski</option>
<option value="pt">Português</option>
@ -77,6 +77,19 @@
<option value="2160">2160p (4k)</option>
</select>
</div>
<br>
<!-- Video Codec -->
<div class="prefBox">
<span id="preferredVideoCodecTxt">Preferred video codec</span>
<select id="preferredVideoCodec">
<option value="avc1">AVC1</option>
<option value="av01">AV1</option>
<option value="vp9">VP9</option>
<option value="mp4v">MP4V</option>
</select>
</div>
<br>
@ -130,8 +143,14 @@
<span id="configPath"></span>
</div>
</div>
<br>
<div class="prefBox">
<span id="showMoreFormatsTxt">Show more format options</span>
<input type="checkbox" class="cb" id="showMoreFormats">
</div>
<br>
<div class="prefBox">
<span id="fileFormatTxt">Filename format for playlists</span>
<input type="text" id="filenameFormat" placeholder="yt-dlp format style"

@ -101,7 +101,6 @@ getId("browser").addEventListener("change", () => {
});
// Handling preferred video quality
let preferredVideoQuality = localStorage.getItem("preferredVideoQuality");
if (preferredVideoQuality) {
getId("preferredVideoQuality").value = preferredVideoQuality;
@ -113,7 +112,6 @@ getId("preferredVideoQuality").addEventListener("change", () => {
});
// Handling preferred audio quality
let preferredAudioQuality = localStorage.getItem("preferredAudioQuality");
if (preferredAudioQuality) {
getId("preferredAudioQuality").value = preferredAudioQuality;
@ -124,6 +122,17 @@ getId("preferredAudioQuality").addEventListener("change", () => {
localStorage.setItem("preferredAudioQuality", preferredAudioQuality);
});
// Handling preferred video codec
let preferredVideoCodec = localStorage.getItem("preferredVideoCodec");
if (preferredVideoCodec) {
getId("preferredVideoCodec").value = preferredVideoCodec;
}
getId("preferredVideoCodec").addEventListener("change", () => {
preferredVideoCodec = getId("preferredVideoCodec").value;
localStorage.setItem("preferredVideoCodec", preferredVideoCodec);
});
// Reload
function reload() {
ipcRenderer.send("reload");
@ -214,5 +223,19 @@ if (autoUpdate == "false"){
autoUpdateDisabled.checked = true;
}
// Show more format options
const showMoreFormats = getId("showMoreFormats");
showMoreFormats.addEventListener("change", (event) => {
if (showMoreFormats.checked) {
localStorage.setItem("showMoreFormats", "true");
} else {
localStorage.setItem("showMoreFormats", "false");
}
});
const showMoreFormatOpts = localStorage.getItem("showMoreFormats")
if (showMoreFormatOpts == "true"){
showMoreFormats.checked = true;
}
// Translation file
require("../src/translate_preferences");

@ -17,19 +17,21 @@ const path = require("path");
const {shell, ipcRenderer, clipboard} = require("electron");
const {default: YTDlpWrap} = require("yt-dlp-wrap-plus");
const {constants} = require("fs/promises");
const { stdout } = require("process");
const {stdout} = require("process");
// Directories
const homedir = os.homedir();
let appdir = path.join(homedir, "Downloads");
if (os.platform() === "linux") {
try {
const xdgDownloadDir = cp.execSync("xdg-user-dir DOWNLOAD").toString().trim()
const xdgDownloadDir = cp
.execSync("xdg-user-dir DOWNLOAD")
.toString()
.trim();
if (xdgDownloadDir.length > 1) {
appdir = xdgDownloadDir
console.log("xdg download dir:", xdgDownloadDir)
appdir = xdgDownloadDir;
console.log("xdg download dir:", xdgDownloadDir);
}
} catch (err) {}
}
const hiddenDir = path.join(homedir, ".ytDownloader");
@ -59,7 +61,8 @@ let rangeOption = "--download-sections";
let cookieArg = "";
let browser = "";
let maxActiveDownloads = 5;
let showVcodec = true;
let showMoreFormats = false;
function checkMaxDownloads() {
if (localStorage.getItem("maxActiveDownloads")) {
const number = Number(localStorage.getItem("maxActiveDownloads"));
@ -88,6 +91,7 @@ let controllers = new Object();
// Video and audio preferences
let preferredVideoQuality = "";
let preferredAudioQuality = "";
let preferredVideoCodec = "avc1";
function getId(id) {
return document.getElementById(id);
@ -268,6 +272,14 @@ async function getInfo(url) {
preferredAudioQuality = localStorage.getItem("preferredAudioQuality");
getId("extractSelection").value = preferredAudioQuality;
}
if (localStorage.getItem("preferredVideoCodec")) {
preferredVideoCodec = localStorage.getItem("preferredVideoCodec");
}
if (localStorage.getItem("showMoreFormats") === "true") {
showMoreFormats = true;
} else {
showMoreFormats = false;
}
// Whether to use browser cookies or not
if (localStorage.getItem("browser")) {
@ -347,6 +359,7 @@ async function getInfo(url) {
let audioSize = 0;
let defaultVideoFormat = 0;
let videoFormatCodecs = {};
let preferredAudioFormatLength = 0;
let preferredAudioFormatCount = 0;
@ -357,10 +370,18 @@ async function getInfo(url) {
// Find the item with the preferred video format
if (
format.height <= preferredVideoQuality &&
format.height > defaultVideoFormat &&
format.height >= defaultVideoFormat &&
format.video_ext !== "none"
) {
defaultVideoFormat = format.height;
// Creating a list of available codecs for the required video height
if (!videoFormatCodecs[format.height]) {
videoFormatCodecs[format.height] = {codecs: []};
}
videoFormatCodecs[format.height].codecs.push(
format.vcodec.split(".")[0]
);
}
// Going through audio list
@ -385,12 +406,25 @@ async function getInfo(url) {
preferredAudioFormatLength++;
}
}
const availableCodecs =
videoFormatCodecs[defaultVideoFormat].codecs;
if (!availableCodecs.includes(preferredVideoCodec)) {
preferredVideoCodec =
availableCodecs[availableCodecs.length - 1];
}
for (let format of formats) {
let size;
let selectedText = "";
let audioSelectedText = "";
if (format.height == defaultVideoFormat && !selected) {
if (
format.height == defaultVideoFormat &&
format.vcodec.split(".")[0] === preferredVideoCodec &&
!selected
) {
selectedText = " selected ";
selected = true;
}
@ -434,26 +468,29 @@ async function getInfo(url) {
// Video codec
const vcodec =
format.vcodec && showVcodec
format.vcodec && showMoreFormats
? format.vcodec.split(".")[0]
: "";
let spaceAfterVcodec = showVcodec
let spaceAfterVcodec = showMoreFormats
? "&#160".repeat(5 - vcodec.length)
: "";
showVcodec
showMoreFormats
? (spaceAfterVcodec += "| ")
: (spaceAfterVcodec += "");
// Quality
const quality = format.height
? format.height + "p" + (format.fps == 60 ? "60" : "")
: "" ||
format.resolution ||
i18n.__(format.format_note) ||
format.format_id ||
"Unknown quality";
const quality =
format.format_note ||
(format.height
? format.height +
"p" +
(format.fps == 60 ? "60" : "")
: "") ||
format.resolution ||
format.format_id ||
"Unknown quality";
const spaceAfterQuality = "&#160".repeat(
8 - quality.length
12 - quality.length
);
// Extension

@ -106,5 +106,7 @@
"Frappé":"Frappé",
"One Dark":"One Dark",
"Matrix":"Matrix",
"Solarized Dark": "Solarized Dark"
"Solarized Dark": "Solarized Dark",
"Preferred video codec": "Preferred video codec",
"Show more format options": "Show more format options"
}

Loading…
Cancel
Save