-
- ${result.title}
- ${result.description}
-
- ${result.channel.name}
-
+
-
`
- console.log(result)
}
res.send(html.replace("{RESULTS}", addedHTML))
@@ -136,20 +140,20 @@ app.get("/video", async (req, res) => {
var debounce = true
var dp = 0
- ytdl(id, { filter: "videoandaudio", quality: "highest", format: 'mp4' })
+ ytdl(id, { filter: 'videoandaudio', quality: "highest", format: 'mp4' })
.on("progress", (chunk, ct, et) => {
- if (debounce) {
+ if (debounce && ct > Math.min(et, 5000000)) {
debounce = false
videoCache[id] = {
"path": vidpath,
"size": et,
"downloaded": false,
"download%": 0
- }
+ }
ready(vidpath, fs.readFileSync(vidpath))
}
var percent = Math.round(ct / et * 100)
- if (percent > dp) {
+ if (!debounce && percent > dp) {
dp = percent
videoCache[id]["download%"] = dp
}
@@ -206,7 +210,7 @@ app.get("/watch", async (req, res) => {
if (!(id in videoCache && videoCache[id]["downloaded"] == true)) {
html = html.replace("{CACHE_WARNING}", `
Please note that this video has not been fully cached, and may have trouble loading!
-
{DOWNLOAD_PERCENT}% cached (as of page load).
+
{DOWNLOAD_PERCENT}% cached as of page load. If content fails to load after a minute, reload the page!
`)
if (id in videoCache && "download%" in videoCache[id]) {
html = html.replace("{DOWNLOAD_PERCENT}", videoCache[id]["download%"])
diff --git a/resources/player.html b/resources/player.html
index a37005a..1a1153b 100644
--- a/resources/player.html
+++ b/resources/player.html
@@ -32,10 +32,10 @@
{VIDEO_TITLE}
- {CACHE_WARNING}
+ {CACHE_WARNING}
Description:
-
{VIDEO_DESCRIPTION}
+
{VIDEO_DESCRIPTION}