More changes

pull/9/head
aandrew-me 3 years ago
parent 145b8b41e7
commit 50f6058aa1

@ -258,7 +258,7 @@ label {
border: none;
outline: none;
border-radius: 5px;
width: 60px;
width: 70px;
font-size: large;
margin: 5px;
}

@ -99,9 +99,9 @@
<div id="advanced">
<p>Download particular time-range</p>
<label>Start</label>
<input type="text" name="startTime" class="time">
<input type="text" id="startTime" class="time" placeholder="00:00">
:
<input type="text" name="endTime" class="time">
<input type="text" id="endTime" class="time" placeholder="11:27">
<label>End</label>
</div>

@ -16,7 +16,9 @@ fs.mkdirSync(tempDir, { recursive: true });
let downloadDir = "";
// Global variables
let title, onlyvideo, id, thumbnail, ytdlp;
let title, onlyvideo, id, thumbnail, ytdlp, duration;
let rangeCmd = "";
let rangeOption = "--download-sections";
let willBeSaved = true;
function getId(id) {
@ -150,6 +152,7 @@ async function getInfo(url) {
title = info.title;
id = info.id;
thumbnail = info.thumbnail;
duration = info.duration;
const formats = info.formats;
console.log(formats);
@ -334,12 +337,51 @@ getId("audioDownload").addEventListener("click", (event) => {
// }
// }
// restorePrevious()
// Time formatting
// function timeFormat(duration) {
// // Hours, minutes and seconds
// var hrs = ~~(duration / 3600);
// var mins = ~~((duration % 3600) / 60);
// var secs = ~~duration % 60;
// // Ouput like "1:01" or "4:03:59" or "123:03:59"
// var ret = "";
// if (hrs > 0) {
// ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
// }
// ret += "" + mins + ":" + (secs < 10 ? "0" : "");
// ret += "" + secs;
// return ret;
// }
// Manage advanced options
// function manageAdvanced(duration) {
// let startTime = getId("startTime").value;
// let endTime = getId("endTime").value;
// if (startTime && !endTime) {
// rangeCmd = `*${startTime}-${timeFormat(duration)}`;
// } else if (!startTime && endTime) {
// rangeCmd = `*0-${endTime}`;
// } else if (startTime && endTime) {
// rangeCmd = `*${startTime}-${endTime}`;
// } else {
// rangeOption = "";
// }
// console.log("Range option: " + rangeOption);
// console.log("rangeCmd:" + rangeCmd);
// }
//////////////////////////////
// Downloading with yt-dlp
//////////////////////////////
function download(type) {
// manageAdvanced(duration);
const url = getId("url").value;
let ext;
@ -441,6 +483,8 @@ function download(type) {
downloadProcess = ytdlp.exec(
[
url,
// rangeOption,
// rangeCmd,
"-f",
`${format_id}+${audioFormat}`,
"-o",
@ -457,6 +501,8 @@ function download(type) {
downloadProcess = ytdlp.exec(
[
url,
rangeOption,
rangeCmd,
"-f",
format_id,
"-o",
@ -507,8 +553,9 @@ function download(type) {
}
})
.on("error", (error) => {
getId(randomId + "prog").textContent = "Some error has occured"
})
getId(randomId + "prog").textContent = "Some error has occured";
console.log(error);
});
}
// Removing item

Loading…
Cancel
Save