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 | ✔️ | | Greek | ✔️ |
| Hungarian | ✔️ | | Hungarian | ✔️ |
| Italian | ✔️ | | Italian | ✔️ |
| Japanese | ✔️ |
| Persian | ✔️ | | Persian | ✔️ |
| Polish | ✔️ | | Polish | ✔️ |
| Portuguese (Brazil) | ✔️ | | Portuguese (Brazil) | ✔️ |
@ -138,7 +139,7 @@ Translations into other languages would be highly appreciated. If you want to he
| Ukrainian | ✔️ | | Ukrainian | ✔️ |
| Vietnamese | ✔️ | | 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 ## Used technologies

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

@ -44,13 +44,13 @@
<label id="selectLn">Select Language (Requires reload)</label> <label id="selectLn">Select Language (Requires reload)</label>
<select id="select" onchange="changeLanguage()"> <select id="select" onchange="changeLanguage()">
<option value="en">English</option> <option value="en">English</option>
<option value="de">Deutsch</option> <option value="de">Deutsch</option>
<option value="es">Español</option> <option value="es">Español</option>
<option value="fa">فارسی</option> <option value="fa">فارسی</option>
<option value="el">Ελληνικά</option> <option value="el">Ελληνικά</option>
<option value="fr">Français</option> <option value="fr">Français</option>
<option value="it">Italiano</option> <option value="it">Italiano</option>
<option value="ja">Japanese</option>
<option value="hu">Magyar</option> <option value="hu">Magyar</option>
<option value="pl">Polski</option> <option value="pl">Polski</option>
<option value="pt">Português</option> <option value="pt">Português</option>
@ -77,6 +77,19 @@
<option value="2160">2160p (4k)</option> <option value="2160">2160p (4k)</option>
</select> </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> </div>
<br> <br>
@ -130,8 +143,14 @@
<span id="configPath"></span> <span id="configPath"></span>
</div> </div>
</div> </div>
<br>
<div class="prefBox">
<span id="showMoreFormatsTxt">Show more format options</span>
<input type="checkbox" class="cb" id="showMoreFormats">
</div>
<br> <br>
<div class="prefBox"> <div class="prefBox">
<span id="fileFormatTxt">Filename format for playlists</span> <span id="fileFormatTxt">Filename format for playlists</span>
<input type="text" id="filenameFormat" placeholder="yt-dlp format style" <input type="text" id="filenameFormat" placeholder="yt-dlp format style"

@ -101,7 +101,6 @@ getId("browser").addEventListener("change", () => {
}); });
// Handling preferred video quality // Handling preferred video quality
let preferredVideoQuality = localStorage.getItem("preferredVideoQuality"); let preferredVideoQuality = localStorage.getItem("preferredVideoQuality");
if (preferredVideoQuality) { if (preferredVideoQuality) {
getId("preferredVideoQuality").value = preferredVideoQuality; getId("preferredVideoQuality").value = preferredVideoQuality;
@ -113,7 +112,6 @@ getId("preferredVideoQuality").addEventListener("change", () => {
}); });
// Handling preferred audio quality // Handling preferred audio quality
let preferredAudioQuality = localStorage.getItem("preferredAudioQuality"); let preferredAudioQuality = localStorage.getItem("preferredAudioQuality");
if (preferredAudioQuality) { if (preferredAudioQuality) {
getId("preferredAudioQuality").value = preferredAudioQuality; getId("preferredAudioQuality").value = preferredAudioQuality;
@ -124,6 +122,17 @@ getId("preferredAudioQuality").addEventListener("change", () => {
localStorage.setItem("preferredAudioQuality", preferredAudioQuality); 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 // Reload
function reload() { function reload() {
ipcRenderer.send("reload"); ipcRenderer.send("reload");
@ -214,5 +223,19 @@ if (autoUpdate == "false"){
autoUpdateDisabled.checked = true; 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 // Translation file
require("../src/translate_preferences"); require("../src/translate_preferences");

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

@ -106,5 +106,7 @@
"Frappé":"Frappé", "Frappé":"Frappé",
"One Dark":"One Dark", "One Dark":"One Dark",
"Matrix":"Matrix", "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