diff --git a/index.js b/index.js index 8acf44c..cf1062e 100644 --- a/index.js +++ b/index.js @@ -35,61 +35,66 @@ function searchResultToHTML(results) { var addedHTML = "" for (let index = 0; index < results.length; index++) { const result = results[index].content || results[index]; - if (result && result.type == "Video" && result.published && result.duration != "N/A") { - if (!result.description_snippet) { - if (result.snippets) { - result.description_snippet = result.snippets[0].text.runs[0] - } else { - result.description_snippet = {text: ''} + try { + if (result && result.type == "Video" && result.published && result.duration.text != "N/A" && result.thumbnails && result.author.thumbnails) { + if (!result.description_snippet) { + if (result.snippets) { + result.description_snippet = result.snippets[0].text.runs[0] + } else { + result.description_snippet = {text: ''} + } } - } - videosHTML += ` -
-
- - -
- - - ${result.author.name} - + videosHTML += ` + -
- ` - } else if (result.type == "Channel" && result.author.thumbnails[0]) { - channelsHTML += ` -
-
- - - ` - } else { - console.log(result.type) + ` + } else { + console.log(result.type) + } + } catch (error) { + console.error(error) + console.log(result) } } @@ -100,6 +105,8 @@ function searchResultToHTML(results) { addedHTML += videosHTML } + addedHTML += "" + return addedHTML } @@ -140,10 +147,10 @@ app.get("/search", async (req, res) => { 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/resources/mainPage.html b/resources/mainPage.html index 5bbcd7c..1d812be 100644 --- a/resources/mainPage.html +++ b/resources/mainPage.html @@ -27,11 +27,12 @@

Welcome to SimpleTube

SimpleTube is a Youtube client that aims to be free, fast, and javascript free. (and has no ads!)

-

- Codeberg +

+ Codeberg

-
+

Loading...

+
{RESULTS}
diff --git a/static/mainStyle.css b/static/mainStyle.css index 7e15958..19f7bb2 100644 --- a/static/mainStyle.css +++ b/static/mainStyle.css @@ -1,5 +1,6 @@ body, html { min-height: 100vh; + widtH: 100vw; padding: 0; margin: 0; background-color: rgb(40, 30, 50); @@ -11,12 +12,12 @@ body, html { line-height: 1.5rem; } -/* div { +.results { padding: 0 !important; margin: 0 !important; -} */ +} -a:not(h1 > a):not(.videoLink) { +.chip { font-size: 1.25rem; background-color: black; padding: 8px; @@ -25,7 +26,7 @@ a:not(h1 > a):not(.videoLink) { border-radius: 8px; color: rgb(240, 220, 255); text-decoration: none; - display: inline; + display: inline-block; } .videoLink { @@ -158,11 +159,11 @@ p { margin: 5px auto; } -.thumbparent { +/* .thumbparent { justify-content: center; align-items: center; display: flex; -} +} */ /* @media (max-width: 1200px) and (min-width: 992px) { .resultDescription { @@ -181,7 +182,7 @@ p { } main { - padding: 5px; + padding: 15px; } .pfp {