Improve error messages

pull/112/head
Andrew 3 years ago
parent d00a06efd0
commit d2ad8e36ef

@ -10,7 +10,7 @@
} }
body { body {
font-family:sans-serif; font-family: sans-serif;
text-align: center; text-align: center;
padding: 10px; padding: 10px;
background-color: var(--background); background-color: var(--background);
@ -95,9 +95,9 @@ body {
color: white; color: white;
} }
#pasteUrl{ #pasteUrl {
display:none; display: none;
margin-top:15px; margin-top: 15px;
font-weight: bold; font-weight: bold;
} }
@ -113,18 +113,17 @@ body {
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
.playlistItem{ .playlistItem {
display: flex; display: flex;
position: relative; position: relative;
width: 86%; width: 86%;
background-color: var(--item-bg); background-color: var(--item-bg);
color: var(--text); color: var(--text);
padding:10px 25px; padding: 10px 25px;
border-radius: 25px; border-radius: 25px;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
margin: 10px auto; margin: 10px auto;
} }
@media screen and (max-width: 650px) { @media screen and (max-width: 650px) {
@ -153,7 +152,7 @@ body {
.itemProgress { .itemProgress {
font-weight: bold; font-weight: bold;
cursor: pointer; cursor: pointer;
margin-top:10px; margin-top: 10px;
font-family: sans-serif; font-family: sans-serif;
} }
.itemClose { .itemClose {
@ -165,7 +164,7 @@ body {
width: 15px; width: 15px;
height: 15px; height: 15px;
} }
.itemType{ .itemType {
font-style: italic; font-style: italic;
margin-top: 5px; margin-top: 5px;
} }
@ -196,17 +195,17 @@ body {
color: var(--text); color: var(--text);
} }
#audioExtract{ #audioExtract {
margin:10px; margin: 10px;
padding:10px; padding: 10px;
background-color: var(--box-toggle); background-color: var(--box-toggle);
border-radius: 10px; border-radius: 10px;
} }
#options{ #options {
display:none; display: none;
position:relative; position: relative;
top:20px; top: 20px;
background-color: var(--box-main); background-color: var(--box-main);
border-radius: 10px; border-radius: 10px;
padding: 10px; padding: 10px;
@ -251,17 +250,17 @@ label {
display: none; display: none;
} }
input[type="checkbox"]{ input[type="checkbox"] {
width:20px; width: 20px;
height:20px; height: 20px;
position: relative; position: relative;
left:5px; left: 5px;
top:4px; top: 4px;
} }
input[type=number]::-webkit-inner-spin-button, input[type="number"]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { input[type="number"]::-webkit-outer-spin-button {
appearance: none; appearance: none;
} }
.submitBtn { .submitBtn {
@ -300,7 +299,8 @@ input[type=number]::-webkit-outer-spin-button {
width: 100px; width: 100px;
} }
.time, .input { .time,
.input {
padding: 8px; padding: 8px;
border: none; border: none;
outline: none; outline: none;
@ -311,9 +311,22 @@ input[type=number]::-webkit-outer-spin-button {
} }
#incorrectMsg { #incorrectMsg {
color: rgb(250, 59, 59); color: rgb(237, 67, 67);
} }
#errorBtn {
display: none;
}
#errorDetails {
cursor: pointer;
font-family: monospace;
padding:15px;
margin: 10px 0;
border: 2px solid rgb(189, 0, 0);
border-radius: 8px;
display: none;
transition: .5s all;
}
#loadingWrapper { #loadingWrapper {
/* Default is flex */ /* Default is flex */
display: none; display: none;
@ -366,11 +379,11 @@ svg {
#savedMsg { #savedMsg {
cursor: pointer; cursor: pointer;
} }
button{ button {
outline:none; outline: none;
} }
#extractBtn{ #extractBtn {
color: white; color: white;
background-color: rgb(80, 128, 230); background-color: rgb(80, 128, 230);
border: none; border: none;
@ -383,7 +396,7 @@ button{
font-size: large; font-size: large;
} }
#extractBtn:active{ #extractBtn:active {
top: 4px; top: 4px;
margin-bottom: 12px; margin-bottom: 12px;
border: none; border: none;
@ -442,4 +455,17 @@ body::-webkit-scrollbar-thumb {
cursor: pointer; cursor: pointer;
color: white; color: white;
cursor: pointer; cursor: pointer;
} }
#popupText{
display: none;
position:absolute;
right:30px;
bottom: 20px;
padding:10px;
border-radius: 2px;
color:white;
background-color: rgb(80, 80, 224);
cursor: pointer;
transition: .5s all;
}

@ -37,6 +37,8 @@
</div> </div>
<body> <body>
<!-- Popup message -->
<span id="popupText">Text copied</span>
<!-- Theme toggle --> <!-- Theme toggle -->
<div id="themeToggle" onclick="toggle()"> <div id="themeToggle" onclick="toggle()">
@ -71,6 +73,8 @@
</svg> </svg>
</div> </div>
<p id="incorrectMsg"></p> <p id="incorrectMsg"></p>
<button class="advancedToggle" id="errorBtn" onclick="toggleErrorDetails()">Error Details ▼</button>
<div id="errorDetails" onclick="copyErrorToClipboard()"></div>
<br> <br>
<div id="hidden"> <div id="hidden">
@ -134,7 +138,7 @@
</select> </select>
<button id="extractBtn">Extract</button> <button id="extractBtn">Extract</button>
</div> </div>
<!-- Extraction options end --> <!-- Extraction options end -->
@ -142,7 +146,7 @@
<!-- Downloads list --> <!-- Downloads list -->
<div id="list"></div> <div id="list"></div>
<div id="goToTop"></div> <div id="goToTop"></div>
<script> <script>
require("../src/translate_index") require("../src/translate_index")

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

@ -239,10 +239,15 @@ async function getInfo(url) {
onlyvideo = false; onlyvideo = false;
let audioIsPresent = false; let audioIsPresent = false;
downloadPathSelection(); downloadPathSelection();
// Cleaning text
getId("videoFormatSelect").innerHTML = ""; getId("videoFormatSelect").innerHTML = "";
getId("audioFormatSelect").innerHTML = ""; getId("audioFormatSelect").innerHTML = "";
getId("startTime").value = ""; getId("startTime").value = "";
getId("endTime").value = ""; getId("endTime").value = "";
getId("errorBtn").style.display = "none";
getId("errorDetails").style.display = "none";
getId("errorDetails").textContent = "";
if (localStorage.getItem("preferredVideoQuality")) { if (localStorage.getItem("preferredVideoQuality")) {
preferredVideoQuality = localStorage.getItem("preferredVideoQuality"); preferredVideoQuality = localStorage.getItem("preferredVideoQuality");
} }
@ -285,11 +290,19 @@ async function getInfo(url) {
infoProcess.stderr.on("data", (error) => { infoProcess.stderr.on("data", (error) => {
validInfo = false; validInfo = false;
// Error message handling
console.log(error.toString("utf8")); console.log(error.toString("utf8"));
getId("loadingWrapper").style.display = "none"; getId("loadingWrapper").style.display = "none";
getId("incorrectMsg").textContent = i18n.__( getId("incorrectMsg").textContent = i18n.__(
"Some error has occurred. Check your network and use correct URL" "Some error has occurred. Check your network and use correct URL"
); );
getId("errorBtn").style.display = "inline-block";
getId("errorDetails").innerHTML = `
<strong>URL: ${url}</strong>
<br><br>
${error.toString("utf8")}
`;
getId("errorDetails").title = i18n.__("Click to copy");
}); });
infoProcess.on("close", () => { infoProcess.on("close", () => {
@ -1031,6 +1044,26 @@ function fadeItem(id) {
}, 50); }, 50);
} }
// Showing and hiding error details
function toggleErrorDetails() {
const status = getId("errorDetails").style.display;
if (status === "none") {
getId("errorDetails").style.display = "block";
getId("errorBtn").textContent = i18n.__("Error Details") + " ▲";
} else {
getId("errorDetails").style.display = "none";
getId("errorBtn").textContent = i18n.__("Error Details") + " ▼";
}
}
// Copying error txt
function copyErrorToClipboard() {
const error = getId("errorDetails").textContent;
clipboard.writeText(error);
showPopup(i18n.__("Copied text"))
}
// After saving video // After saving video
function afterSave(location, filename, progressId) { function afterSave(location, filename, progressId) {
@ -1080,6 +1113,15 @@ function closeMenu() {
}, 50); }, 50);
} }
// Popup message
function showPopup(text) {
getId("popupText").textContent = text
getId("popupText").style.display = "inline-block";
setTimeout(() => {
getId("popupText").style.display = "none"
}, 2000);
}
// Menu // Menu
getId("preferenceWin").addEventListener("click", () => { getId("preferenceWin").addEventListener("click", () => {

@ -37,3 +37,4 @@ getId("subHeader").textContent = i18n.__("Subtitles");
getId("subTxt").textContent = i18n.__("Download subtitles if available"); getId("subTxt").textContent = i18n.__("Download subtitles if available");
getId("extractHeader").textContent = i18n.__("Extract Audio"); getId("extractHeader").textContent = i18n.__("Extract Audio");
getId("extractBtn").textContent = i18n.__("Extract"); getId("extractBtn").textContent = i18n.__("Extract");
getId("errorBtn").textContent = i18n.__("Error Details")+" ▼"

@ -87,6 +87,8 @@
"Use config file":"Use config file", "Use config file":"Use config file",
"Open app":"Open app", "Open app":"Open app",
"Paste video link":"Paste video link", "Paste video link":"Paste video link",
"Quit":"Quit" "Quit":"Quit",
"Error Details":"Error Details",
"Click to copy":"Click to copy",
"Copied text":"Copied text"
} }

Loading…
Cancel
Save