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}
- ${result.subscriber_count.text}
${(result.description_snippet).text}
- + ` + } else if (result.type == "Channel" && result.author.thumbnails[0]) { + channelsHTML += ` + -SimpleTube is a Youtube client that aims to be free, fast, and javascript free. (and has no ads!)
-- Codeberg +
+ Codeberg
-