More info shown

This commit is contained in:
Violet 2023-10-23 16:02:13 +00:00
parent 66ff3d80d2
commit f0f9edf072

View file

@ -58,11 +58,13 @@ app.get("/getLink", async (req, res) => {
var vidinfo = await ytdl.getBasicInfo(url) var vidinfo = await ytdl.getBasicInfo(url)
res.write(`<p>Beginning download...</p>`)
var lastp = 0 var lastp = 0
var ytvid = ytdl(url, { 'quality': quality, 'format': 'mp4' }) var ytvid = ytdl(url, { 'quality': quality, 'format': 'mp4' })
.on("progress", (data, ctotal, etotal) => { .on("progress", (data, ctotal, etotal) => {
var integer = 1 var integer = 5
var percent = (Math.ceil(ctotal / etotal * 100)) var percent = (Math.ceil(ctotal / etotal * 100))
if (percent % integer == 0 && lastp != percent) { if (percent % integer == 0 && lastp != percent) {
res.write(`<p class="percent" id="percent${percent}">Downloading... ${percent}% (${formatBytes(ctotal)})</p>`) res.write(`<p class="percent" id="percent${percent}">Downloading... ${percent}% (${formatBytes(ctotal)})</p>`)
@ -82,7 +84,7 @@ app.get("/getLink", async (req, res) => {
var proc = new ffmpeg(ytpath) var proc = new ffmpeg(ytpath)
// res.write(`<p>Converting... (May take a while, <a href="https://github.com/Violets-puragtory/NoJS-YTConverter"> doesn't support progress updates yet</a>)</p>`) // res.write(`<p>Converting... (May take a while, <a href="https://github.com/Violets-puragtory/NoJS-YTConverter"> doesn't support progress updates yet</a>)</p>`)
var endpath = ('cached/' + ytdl.getVideoID(url) + String(Math.floor(Math.random() * 100000)) + "Converted." + format) var endpath = ('cached/' + ytdl.getVideoID(url) + String(Math.floor(Math.random() * 100000)) + "Converted." + format)
// res.write(`<p id="convert${0}">Converting... 0% (Potentially Innacurate, Experimental!)</p>`) res.write(`<p>Beginning conversion... Conversion may be slow depending on instance.</p>`)
proc.then(function (video) { proc.then(function (video) {
video video
.setVideoDuration(vidinfo.videoDetails.lengthSeconds) .setVideoDuration(vidinfo.videoDetails.lengthSeconds)
@ -110,7 +112,7 @@ app.get("/getLink", async (req, res) => {
var count = 0 var count = 0
var integer = 1 var integer = 1
var lastc = -1 var lastc = 0
var percent = 0 var percent = 0
async function update() { async function update() {
if (fs.existsSync(endpath)) { if (fs.existsSync(endpath)) {