This commit is contained in:
Bingus_Violet 2023-11-20 10:55:41 -06:00
parent b6de202102
commit 94824f020a
5 changed files with 35 additions and 9 deletions

View file

@ -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 = `<link rel="stylesheet" href="/mainStyle.css">`
const cssHeader = `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="/mainStyle.css">`
const topBar = `
<div id="titleBar" class="row container-fluid">
<div class="col-6">
<h1><a href="/">SimpleTube</a></h1>
</div>
<div class="col-6">
<form action="/search">
<input type="text" placeholder="Search" name="q">
</form>
</div>
</div>
`
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("<h2>Not a valid video id or url!</h2>")
res.end()
return
}
try {
var vidInfo = (await ytdl.getBasicInfo(id)).videoDetails
} catch (error) {
res.write(cssHeader)
res.write(topBar)
res.write("<h2>Failed to get video info! This likely means the video is age restricted, or deleted.</h2>", () => {res.end()})
return
}
var vidInfo = (await ytdl.getBasicInfo(id)).videoDetails
var html = fs.readFileSync(playerPath).toString()

View file

@ -15,7 +15,7 @@
<body>
<div id="titleBar" class="row container-fluid">
<div class="col-6">
<h1><a href="/">Simpletube</a></h1>
<h1><a href="/">SimpleTube</a></h1>
</div>
<div class="col-6">
<form action="/search">

View file

@ -16,7 +16,7 @@
<body>
<div id="titleBar" class="row container-fluid">
<div class="col-6">
<h1><a href="/">Simpletube</a></h1>
<h1><a href="/">SimpleTube</a></h1>
</div>
<div class="col-6">
<form action="/search">

View file

@ -15,7 +15,7 @@
<body>
<div id="titleBar" class="row container-fluid">
<div class="col-6">
<h1><a href="/">Simpletube</a></h1>
<h1><a href="/">SimpleTube</a></h1>
</div>
<div class="col-6">
<form action="/search">

View file

@ -15,7 +15,7 @@
<body>
<div id="titleBar" class="row container-fluid">
<div class="col-6">
<h1><a href="/">Simpletube</a></h1>
<h1><a href="/">SimpleTube</a></h1>
</div>
<div class="col-6">
<form action="/search">