diff --git a/html/index.html b/html/index.html
index eadf308..a52296c 100644
--- a/html/index.html
+++ b/html/index.html
@@ -71,6 +71,7 @@
-
Filename format for playlists
+
Filename format for playlists
@@ -144,7 +144,7 @@
- Folder name format for playlists
+ Folder name format for playlists
diff --git a/src/playlist.js b/src/playlist.js
index 22f15cb..c996845 100644
--- a/src/playlist.js
+++ b/src/playlist.js
@@ -47,6 +47,13 @@ let playlistId = "";
let folderLocation;
function download(type) {
+ // Config file
+ let configArg = "";
+ let configTxt = "";
+ if (localStorage.getItem("configPath")) {
+ configArg = "--config-location";
+ configTxt = localStorage.getItem("configPath");
+ }
// Handling folder and file names
let foldernameFormat = "%(playlist_title)s";
let filenameFormat = "%(playlist_index)s.%(title)s.%(ext)s";
@@ -118,7 +125,8 @@ function download(type) {
ffmpeg,
cookieArg,
browser,
-
+ configArg,
+ configTxt,
`"${url}"`,
],
{ shell: true, detached: false },
@@ -139,7 +147,8 @@ function download(type) {
ffmpeg,
cookieArg,
browser,
-
+ configArg,
+ configTxt,
`"${url}"`,
],
{ shell: true, detached: false },
@@ -171,7 +180,7 @@ function download(type) {
console.log(playlistName);
}
- if (eventData.includes(videoIndex)) {
+ if (eventData.includes(videoIndex) && !eventData.includes("thumbnail")) {
count += 1;
let itemTitle;
if (type === "video") {
@@ -325,3 +334,9 @@ getId("download").textContent = i18n.__("Download");
getId("audioDownload").textContent = i18n.__("Download");
getId("bestVideoOption").textContent = i18n.__("Best");
getId("openDownloads").textContent = i18n.__("Open download folder");
+getId("videoToggle").textContent = i18n.__("Video");
+getId("audioToggle").textContent = i18n.__("Audio");
+getId("advancedToggle").textContent = i18n.__("More options");
+getId("rangeTxt").textContent = i18n.__("Playlist range");
+getId("playlistIndex").placeholder = i18n.__("Start");
+getId("playlistEnd").placeholder = i18n.__("End");
diff --git a/src/renderer.js b/src/renderer.js
index dd78cb5..e5e6de4 100644
--- a/src/renderer.js
+++ b/src/renderer.js
@@ -2,7 +2,7 @@ const cp = require("child_process");
const os = require("os");
let ffmpeg;
if (os.platform() === "win32") {
- ffmpeg = `"${__dirname}\\..\\ffmpeg.exe"`;
+ ffmpeg = `"${__dirname}\\..\\ffmpeg.exe"`;
} else {
ffmpeg = `"${__dirname}/../ffmpeg"`;
}
@@ -33,15 +33,20 @@ let rangeOption = "--download-sections";
let cookieArg = "";
let browser = "";
let maxActiveDownloads = 5;
-if (localStorage.getItem("maxActiveDownloads")){
- const number = Number(localStorage.getItem("maxActiveDownloads"))
- if (number < 1){
- maxActiveDownloads = 1
- }
- else{
- maxActiveDownloads = number
+function checkMaxDownloads(){
+ if (localStorage.getItem("maxActiveDownloads")){
+ const number = Number(localStorage.getItem("maxActiveDownloads"))
+ if (number < 1){
+ maxActiveDownloads = 1
+ }
+ else{
+ maxActiveDownloads = number
+ }
}
}
+checkMaxDownloads()
+
+
let currentDownloads = 0;
let controllers = new Object;
@@ -449,6 +454,7 @@ async function getInfo(url) {
// Video download event
getId("videoDownload").addEventListener("click", (event) => {
+ checkMaxDownloads()
getId("hidden").style.display = "none";
console.log(`Current:${currentDownloads} Max:${maxActiveDownloads}`);
@@ -483,6 +489,7 @@ getId("videoDownload").addEventListener("click", (event) => {
// Audio download event
getId("audioDownload").addEventListener("click", (event) => {
+ checkMaxDownloads()
getId("hidden").style.display = "none";
console.log(`Current:${currentDownloads} Max:${maxActiveDownloads}`);
@@ -515,12 +522,38 @@ getId("audioDownload").addEventListener("click", (event) => {
});
getId("extractBtn").addEventListener("click", () => {
- const value = getId("extractSelection").value;
- extractFormat = value;
- preferredAudioQuality = value;
- localStorage.setItem("preferredAudioQuality", value);
+ checkMaxDownloads()
getId("hidden").style.display = "none";
- download("extract");
+ extractFormat = getId("extractSelection").value;
+
+ console.log(`Current:${currentDownloads} Max:${maxActiveDownloads}`);
+
+ if (currentDownloads < maxActiveDownloads) {
+ download("extract");
+ currentDownloads++;
+ } else {
+ const randId = Math.random().toFixed(10).toString().slice(2);
+ const item = `
+
+

+
+
+
${title}
+
${i18n.__("Video")}
+
${i18n.__("Download pending")}
+
+
+ `;
+ getId("list").innerHTML += item;
+ const interval = setInterval(() => {
+ if (currentDownloads < maxActiveDownloads) {
+ getId(randId).remove()
+ download("extract");
+ currentDownloads++;
+ clearInterval(interval);
+ }
+ }, 2000);
+ }
});
// Restore previous uncompleted downloads
@@ -624,6 +657,15 @@ function manageAdvanced(duration) {
function download(type) {
manageAdvanced(duration);
+
+ // Config file
+ let configArg = ""
+ let configTxt = ""
+ if (localStorage.getItem("configPath")){
+ configArg = "--config-location"
+ configTxt = localStorage.getItem("configPath")
+ }
+
const url = getId("url").value;
let ext;
let extractExt;
@@ -745,6 +787,8 @@ function download(type) {
subs,
subLangs,
"--no-playlist",
+ configArg,
+ `"${configTxt}"`,
cookieArg,
browser,
`"${url}"`,
@@ -772,6 +816,8 @@ function download(type) {
"--no-playlist",
cookieArg,
browser,
+ configArg,
+ `"${configTxt}"`,
`"${url}"`,
],
{ shell: true, detached: false },
@@ -795,6 +841,8 @@ function download(type) {
"--no-playlist",
cookieArg,
browser,
+ configArg,
+ `"${configTxt}"`,
`"${url}"`,
],
{ shell: true, detached: false },
@@ -833,9 +881,9 @@ function download(type) {
getId(randomId + "prog").textContent = i18n.__("Downloading...");
})
.once("close", (code) => {
+ currentDownloads--;
console.log("Closed with code " + code);
if (code == 0) {
- currentDownloads--;
// const items = JSON.parse(localStorage.getItem("itemList"));
// // Clearing item from localstorage
// for (let item of items) {
@@ -883,7 +931,6 @@ function download(type) {
function fadeItem(id) {
controllers[id].abort()
- currentDownloads --;
let count = 0;
let opacity = 1;
const fade = setInterval(() => {
@@ -940,6 +987,7 @@ function closeMenu() {
const fade = setInterval(() => {
if (count >= 10) {
clearInterval(fade);
+ getId("menu").style.display = "none"
} else {
opacity -= 0.1;
getId("menu").style.opacity = opacity;
diff --git a/src/translate_preferences.js b/src/translate_preferences.js
index a4622af..260705d 100644
--- a/src/translate_preferences.js
+++ b/src/translate_preferences.js
@@ -28,3 +28,11 @@ querySelectorAll(".autoTxt").forEach((item) => {
getId("preferredAudioTxt").textContent = i18n.__("Preferred audio format");
getId("preferredVideoTxt").textContent = i18n.__("Preferred video quality");
getId("restart").textContent = i18n.__("Restart app");
+getId("configTxt").textContent = i18n.__("Use configuration file");
+getId("configBtn").textContent = i18n.__("Select config file");
+getId("configPathTxt").textContent = i18n.__("Path:");
+getId("fileFormatTxt").textContent = i18n.__("Filename format for playlists");
+getId("dirFormatTxt").textContent = i18n.__("Folder name format for playlists");
+getId("resetFilenameFormat").textContent = i18n.__("Reset to default");
+getId("resetFoldernameFormat").textContent = i18n.__("Reset to default");
+getId("maxTxt").textContent = i18n.__("Maximum number of active downloads");