diff --git a/index.js b/index.js
index 727da4f..6a5c5d2 100644
--- a/index.js
+++ b/index.js
@@ -16,6 +16,7 @@ const resources = path.join(__dirname, 'resources')
const cachePath = path.join(__dirname, 'cache')
const playerPath = path.join(resources, 'player.html')
+const searchPath = path.join(resources, 'searchPage.html')
const cssHeader = ``
@@ -39,6 +40,44 @@ app.listen(PORT, () => {
console.log("Simpletube is now listening on port: " + PORT)
})
+app.get("/search", async (req, res) => {
+ var search = req.query.q || "How to search on SimpleTube"
+ res.setHeader("Content-Type", "text/html")
+ youtube.search(search).then((results) => {
+ var videos = results.videos
+ var html = fs.readFileSync(searchPath).toString()
+
+ html = html.replace("{SEARCH}", search)
+
+ var addedHTML = ""
+
+ for (let index = 0; index < videos.length; index++) {
+ const result = videos[index];
+ addedHTML += `
+
+
+ `
+ console.log(result)
+ }
+
+ res.send(html.replace("{RESULTS}", addedHTML))
+ })
+})
+
app.get("/video", async (req, res) => {
var id = req.query.q || req.query.v
@@ -134,7 +173,7 @@ app.get("/video", async (req, res) => {
})
app.get("/watch", async (req, res) => {
- var id = req.query.q || req.query.v
+ var id = req.query.q || req.query.v || "ubFq-wV3Eic"
res.setHeader("Content-Type", "text/html")
@@ -157,7 +196,10 @@ app.get("/watch", async (req, res) => {
html = html.replace("{CSS_HEADER}", cssHeader)
- html = html.replace("{VIDEO_TITLE}", vidInfo.title)
+ for (let index = 0; index < 2; index++) {
+ html = html.replace("{VIDEO_TITLE}", vidInfo.title)
+
+ }
html = html.replace("{VIDEO_DESCRIPTION}", vidInfo.description || "No Description.")
diff --git a/resources/player.html b/resources/player.html
index 9197aab..a37005a 100644
--- a/resources/player.html
+++ b/resources/player.html
@@ -5,14 +5,24 @@
- {CSS_HEADER}
+
+
- Document
+
+ {VIDEO_TITLE}
-
-
+