diff --git a/index.js b/index.js
index 15d6829..c55182a 100644
--- a/index.js
+++ b/index.js
@@ -23,7 +23,22 @@ const playerPath = path.join(resources, 'player.html')
const searchPath = path.join(resources, 'searchPage.html')
const channelPath = path.join(resources, 'channelPage.html')
-const cssHeader = ``
+const cssHeader = `
+`
+
+const topBar = `
+
+`
if (fs.existsSync(cachePath)) {
@@ -88,7 +103,7 @@ async function cacher(id, quality, ready) {
var video = ytdl(id, { filter: 'videoandaudio', quality: "highest", format: 'mp4' })
.on("progress", (chunk, ct, et) => {
- if (debounce && (ct / et) > 0.015) {
+ if (debounce && (ct / et) > 0.1) {
debounce = false
videoCache[id + quality] = {
"path": vidpath,
@@ -450,13 +465,24 @@ app.get("/watch", async (req, res) => {
}
if (!ytdl.validateID(id)) {
- res.setHeader("Content-Type", "text/html")
- res.write("Not a valid video id or url!")
+ res.write(cssHeader)
+ res.write(topBar)
+ res.write("Not a valid video id or url!
")
res.end()
return
}
+
+ try {
+ var vidInfo = (await ytdl.getBasicInfo(id)).videoDetails
+ } catch (error) {
+ res.write(cssHeader)
+ res.write(topBar)
+ res.write("Failed to get video info! This likely means the video is age restricted, or deleted.
", () => {res.end()})
+ return
+ }
+
- var vidInfo = (await ytdl.getBasicInfo(id)).videoDetails
+
var html = fs.readFileSync(playerPath).toString()
diff --git a/resources/channelPage.html b/resources/channelPage.html
index 8b6e58d..ca7c555 100644
--- a/resources/channelPage.html
+++ b/resources/channelPage.html
@@ -15,7 +15,7 @@