App quit feature and removing useless code

pull/131/head
Andrew 3 years ago
parent 05294f59d4
commit 3dd713c19d

@ -443,6 +443,17 @@ button {
#advanced {
display: none;
}
.advancedItem{
border: 1.5px solid gray;
border-radius: 10px;
padding:20px;
margin: 10px;
}
#subHeader{
font-weight: bold;
margin-top: 0;
}
/* Scrollbar */

@ -107,26 +107,39 @@
</div>
</div>
<div id="advanced">
<p id="rangeText" title="DASH Webm not supported">Download particular time-range</p>
<label id="start">Start</label>
<input type="text" id="startTime" class="time" placeholder="00:00"
title="If kept empty, it will start from the beginning">
:
<input type="text" id="endTime" class="time" placeholder="10:00"
title="If kept empty, it will be downloaded to the end">
<label id="end">End</label>
<br><br>
<div><span id="clText">Current download location - </span><span id="path"></span></div>
<br><br>
<button id="selectLocation" class="submitBtn">Select Download Location</button>
<br><br>
<h3 id="subHeader">Subtitles</h3>
<span id="subTxt">Download subtitles if available</span>
<input id="subChecked" class="cb" type="checkbox">
<div class="advancedItem">
<span id="quitTxt">Close app when download finishes</span>
<input type="checkbox" id="quitChecked" class="cb">
</div>
<div class="advancedItem">
<strong id="rangeText" title="DASH Webm not supported">Download particular time-range</strong>
<br><br>
<label id="start">Start</label>
<input type="text" id="startTime" class="time" placeholder="00:00"
title="If kept empty, it will start from the beginning">
:
<input type="text" id="endTime" class="time" placeholder="10:00"
title="If kept empty, it will be downloaded to the end">
<label id="end">End</label>
</div>
<div class="advancedItem">
<div><span id="clText">Current download location - </span><span id="path"></span></div>
<br>
<button id="selectLocation" class="submitBtn">Select Download Location</button>
</div>
<div class="advancedItem">
<p id="subHeader">Subtitles</p>
<span id="subTxt">Download subtitles if available</span>
<input id="subChecked" class="cb" type="checkbox">
</div>
</div>
<!-- Extraction options start -->

@ -247,6 +247,10 @@ ipcMain.on("select-config", () => {
}
});
ipcMain.on("quit", ()=>{
app.quit()
})
// Auto update
let autoUpdate = false;

@ -677,44 +677,6 @@ getId("extractBtn").addEventListener("click", () => {
}
});
// Restore previous uncompleted downloads
// function restorePrevious() {
// if (!localStorage.getItem("itemList")) return;
// const items = JSON.parse(localStorage.getItem("itemList"));
// if (items) {
// console.log(items);
// items.forEach((item) => {
// const newItem = `
// <div class="item" id="${item.id}">
// <img src="../assets/images/close.png" onClick="fadeItem('${
// item.id
// }')" class="itemClose"}" id="${item.id + ".close"}">
// <img src="${item.thumbnail}" alt="thumbnail" class="itemIcon">
// <div class="itemBody">
// <div class="itemTitle">${item.title}</div>
// <div class="itemType">${item.type}</div>
// <input disabled type="range" value="0" class="hiddenVideoProgress" id="${
// item.id + "vid"
// }"></input>
// <input disabled type="range" value="0" class="hiddenAudioProgress" id="${
// item.id + "aud"
// }"></input>
// <div id="${item.id + "prog"}" class="itemProgress">Progress: ${
// item.progress
// }%</div>
// <button class="resumeBtn">Resume</button>
// </div>
// </div>
// `;
// getId("list").innerHTML += newItem;
// });
// }
// }
// restorePrevious()
// Time formatting
function timeFormat(duration) {
@ -795,6 +757,9 @@ function download(
let format_id;
const randomId = "a" + Math.random().toFixed(10).toString().slice(2);
// Whether to close app
let quit = Boolean(getId("quitChecked").checked)
if (type === "video") {
const videoValue = getId("videoFormatSelect").value;
format_id = videoValue.split("|")[0];
@ -812,23 +777,6 @@ function download(
}
console.log("video extension:", ext);
// localStorage.setItem("itemList", "");
// let itemList = [];
// if (localStorage.getItem("itemList")) {
// itemList = JSON.parse(localStorage.getItem("itemList"));
// }
// const itemInfo = {
// id: randomId,
// format_id: format_id,
// title: title,
// url: url,
// ext: ext,
// type: type,
// thumbnail: thumbnail,
// };
// itemList.push(itemInfo);
// localStorage.setItem("itemList", JSON.stringify(itemList));
const newItem = `
<div class="item" id="${randomId}">
<div class="itemIconBox">
@ -923,8 +871,6 @@ function download(
`"${path.join(downloadDir, filename + `.${ext}`)}"`,
"--ffmpeg-location",
ffmpeg,
// "--downloader",
// `'m3u8,dash:${ffmpeg}'`,
subs1 || subs,
subs2 || subLangs,
"--no-playlist",
@ -955,8 +901,6 @@ function download(
`"${path.join(downloadDir, filename + `.${extractExt}`)}"`,
"--ffmpeg-location",
ffmpeg,
// "--downloader",
// `'m3u8,dash:${ffmpeg}'`,
"--no-playlist",
cookieArg,
browser,
@ -983,8 +927,6 @@ function download(
`"${path.join(downloadDir, filename + `.${ext}`)}"`,
"--ffmpeg-location",
ffmpeg,
// "--downloader",
// `'m3u8:${ffmpeg}'`,
subs1 || subs,
subs2 || subLangs,
"--no-playlist",
@ -1017,16 +959,6 @@ function download(
randomId + "prog"
).innerHTML = `<progress class="progressBar" min=0 max=100 value=${progress.percent}>`;
}
// const items = JSON.parse(localStorage.getItem("itemList"));
// // Clearing item from localstorage
// for (let item of items) {
// if (item.id == randomId) {
// item.progress = progress.percent;
// break;
// }
// }
// localStorage.setItem("itemList", JSON.stringify(items));
})
.once("ytDlpEvent", (eventType, eventData) => {
getId(randomId + "prog").textContent = i18n.__("Downloading...");
@ -1036,16 +968,6 @@ function download(
currentDownloads--;
console.log("Closed with code " + code);
if (code == 0) {
// const items = JSON.parse(localStorage.getItem("itemList"));
// // Clearing item from localstorage
// for (let item of items) {
// if (item.id == randomId) {
// items.splice(items.indexOf(item), 1);
// break;
// }
// }
// localStorage.setItem("itemList", JSON.stringify(items));
// If extration is done
if (type === "extract") {
console.log(
@ -1068,6 +990,10 @@ function download(
);
}
}
if (quit) {
console.log("Quitting app")
quitApp()
}
})
.once("error", (error) => {
currentDownloads--;
@ -1079,6 +1005,10 @@ function download(
});
}
function quitApp(){
ipcRenderer.send("quit","quit")
}
// Removing item
function fadeItem(id) {

@ -97,5 +97,6 @@
"Worst":"Worst",
"Select Quality":"Select Quality",
"Disable auto updates":"Disable auto updates",
"ultralow":"ultralow"
"ultralow":"ultralow",
"Close app when download finishes":"Close app when download finishes"
}

Loading…
Cancel
Save