diff --git a/index.js b/index.js
index 64997ef..fc69c6c 100644
--- a/index.js
+++ b/index.js
@@ -30,11 +30,20 @@ function getThumbor() {
}
function searchResultToHTML(results) {
+ var videosHTML = "
@@ -46,7 +55,7 @@ function searchResultToHTML(results) {
@@ -59,9 +68,38 @@ function searchResultToHTML(results) {
`
+ } else if (result.type == "Channel" && result.author.thumbnails[0]) {
+ channelsHTML += `
+
+ `
+ } else {
+ console.log(result.type)
}
}
+ if (channelsHTML.length > 30) {
+ addedHTML += channelsHTML
+ }
+ if (videosHTML.length > 30) {
+ addedHTML += videosHTML
+ }
+
return addedHTML
}
@@ -83,6 +121,7 @@ app.get("/", async (req, res) => {
})
app.get("/search", async (req, res) => {
+ var search = req.query.q
var innerTube = await ytjs.Innertube.create()
res.setHeader("Content-Type", "text/html")
@@ -90,19 +129,21 @@ app.get("/search", async (req, res) => {
var html = fs.readFileSync(path.join(resources, 'searchPage.html')).toString()
+ html = html.replaceAll("{SEARCH}", search)
+
res.write(html.substring(0, html.indexOf("{RESULTS}")))
- var results = (await innerTube.search('test'))
+ var results = (await innerTube.search(search, {type: "all"}))
var addedHTML = searchResultToHTML(results.results)
res.write(addedHTML + html.substring(html.indexOf("{RESULTS}") + 9), () => {res.end()})
})
-process.on('uncaughtException', (err, origin) => {
- fs.writeSync(
- process.stderr.fd,
- `Caught exception: ${err}\n` +
- `Exception origin: ${origin}`,
- );
-});
\ No newline at end of file
+// process.on('uncaughtException', (err, origin) => {
+// fs.writeSync(
+// process.stderr.fd,
+// `Caught exception: ${err}\n` +
+// `Exception origin: ${origin}`,
+// );
+// });
\ No newline at end of file
diff --git a/static/mainStyle.css b/static/mainStyle.css
index 259ed07..7e15958 100644
--- a/static/mainStyle.css
+++ b/static/mainStyle.css
@@ -196,6 +196,11 @@ hr {
margin: 20px auto;
}
+.note {
+ color: darkgray;
+ font-size: 0.9rem
+}
+
#channelBar {
background-color: rgb(15, 10, 25);
border-bottom: 2px gray solid;