Invidious is an alternative front-end to YouTube
Use alternate thumbnail url for search page
Omar Rothe89f15a65c23
diff --git a/src/invidious.cr b/src/invidious.crindex 1233bf5b..67bbc875 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -321,12 +321,13 @@ get "/search" do |env|if rootvideo = {} of String => String- link = root.xpath_node(%q(div[contains(@class,"yt-lockup-thumbnail")]/a/@href))- if link- video["link"] = link.content+ id = root.xpath_node(%q(div[contains(@class,"yt-lockup-thumbnail")]/a/@href))+ if id+ id = id.content.lchop("/watch?v=")else- video["link"] = "#"+ id = ""end+ video["id"] = idtitle = root.xpath_node(%q(div[@class="yt-lockup-content"]/h3/a))if title@@ -335,25 +336,13 @@ get "/search" do |env|video["title"] = "Something went wrong"end- thumbnail = root.xpath_node(%q(div[contains(@class,"yt-lockup-thumbnail")]/a/div/span/img/@src))- if thumbnail && !thumbnail.content.ends_with?(".gif")- video["thumbnail"] = thumbnail.content- else- thumbnail = root.xpath_node(%q(div[contains(@class,"yt-lockup-thumbnail")]/a/div/span/img/@data-thumb))- if thumbnail- video["thumbnail"] = thumbnail.content- else- video["thumbnail"] = "https://dummyimage.com/246x138"- end- end-author = root.xpath_node(%q(div[@class="yt-lockup-content"]/div/a))if authorvideo["author"] = author.content- video["author_url"] = author["href"]+ video["ucid_url"] = author["href"]elsevideo["author"] = ""- video["author_url"] = ""+ video["ucid_url"] = ""endvideos << videodiff --git a/src/views/search.ecr b/src/views/search.ecrindex b1fcf62c..3da7f42f 100644--- a/src/views/search.ecr+++ b/src/views/search.ecr@@ -7,12 +7,12 @@<% slice.each do |video| %><div class="pure-u-1 pure-u-md-1-4"><div style="overflow-wrap:break-word; word-wrap:break-word;" class="h-box">- <a style="width:100%;" href="<%= video["link"] %>">- <img style="width:100%;" src="<%= video["thumbnail"] %>"/>+ <a style="width:100%;" href="/watch?v=<%= video["id"] %>">+ <img style="width:100%;" src="https://i1.ytimg.com/vi/<%= video["id"] %>/mqdefault.jpg"/><p><%= video["title"] %></p></a><p>- <b><a style="width:100%;" href="<%= video["author_url"]%>"><%= video["author"] %></a></b>+ <b><a style="width:100%;" href="https://youtube.com<%= video["ucid_url"]%>"><%= video["author"] %></a></b></p></div></div>