Fixed block and other things

This commit is contained in:
Violet 2023-10-25 21:04:42 +00:00
parent f1a07dff8f
commit ab698f112b
2 changed files with 20 additions and 19 deletions

View file

@ -47,7 +47,7 @@ app.get("/getLink", async (req, res) => {
if (!ytdl.validateURL(url)) { if (!ytdl.validateURL(url)) {
res.header("Content-Type", "text/html") res.header("Content-Type", "text/html")
res.write(`<link rel="stylesheet" href="/style.css">`) res.write(`<link rel="stylesheet" href="/style.css">`)
res.write(`<p>Invalid URL! Check the url for any errors! <br> ${url}</p>`) res.write(`<p>Invalid URL! Check the url for any errors! <br>URL: ${url}</p>`)
return return
} }
if (["mp4", "webm"].includes(format)) { if (["mp4", "webm"].includes(format)) {
@ -67,6 +67,13 @@ app.get("/getLink", async (req, res) => {
res.setHeader("Content-Type", "text/html"); res.setHeader("Content-Type", "text/html");
res.write(`<link rel="stylesheet" href="/style.css">`) res.write(`<link rel="stylesheet" href="/style.css">`)
res.write(`
<style>
p {
display: block;
}
</style>
`)
} }
@ -148,16 +155,11 @@ app.get("/getLink", async (req, res) => {
}) })
var count = 0 var count = 0
var integer = 1
var lastc = 0
var percent = 0
async function update() { async function update() {
if (fs.existsSync(endpath)) { if (fs.existsSync(endpath)) {
var ffile = await fs.readFileSync(endpath) var ffile = await fs.readFileSync(endpath)
var yt = await fs.readFileSync(ytpath) var yt = await fs.readFileSync(ytpath)
percent = (Math.round(ffile.length / yt.length * (100 / integer))) * integer
// console.log(ffile.length)
// if (ffile.length != lastc) {
res.write(`<p class="cv" id="convert${count}">Converting... (${formatBytes(ffile.length)})</p>`) res.write(`<p class="cv" id="convert${count}">Converting... (${formatBytes(ffile.length)})</p>`)
res.write(` res.write(`
<style> <style>
@ -166,11 +168,10 @@ app.get("/getLink", async (req, res) => {
} }
</style> </style>
`) `)
lastc = percent
count += 1 count += 1
// } // }
} }
if (percent < 100 && redir != "redirect") { if ( redir != "redirect") {
setTimeout(() => { setTimeout(() => {
update() update()
}, 2000); }, 2000);

View file

@ -24,7 +24,7 @@ input {
p { p {
margin: 5px; margin: 5px;
display: inline-block display: inline-block;
} }
body, body,