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 = ` +
+
+

SimpleTube

+
+
+
+ +
+
+
+` 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 @@
-

Simpletube

+

SimpleTube

diff --git a/resources/player.html b/resources/player.html index a69f3ed..f69f754 100644 --- a/resources/player.html +++ b/resources/player.html @@ -16,7 +16,7 @@
diff --git a/resources/searchPage.html b/resources/searchPage.html index 31f6f66..f77e022 100644 --- a/resources/searchPage.html +++ b/resources/searchPage.html @@ -15,7 +15,7 @@
diff --git a/static/index.html b/static/index.html index 469e204..33f3af8 100644 --- a/static/index.html +++ b/static/index.html @@ -15,7 +15,7 @@