From b5f8b4542aea3d0bb56dc682058cfdf8e666099e Mon Sep 17 00:00:00 2001 From: Chunky programmer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Wed, 7 Jun 2023 16:04:14 -0400 Subject: [PATCH 1/2] Search: Don't error if AuthorId does not exist --- src/invidious/views/components/item.ecr | 36 ++++++++++++++++++------- src/invidious/yt_backend/extractors.cr | 4 +-- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index 031b46da..6d227cfc 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -82,11 +82,19 @@
-
-

<%= HTML.escape(item.author) %> - <%- if author_verified %> <% end -%> -

-
+
+ <% if !item.ucid.to_s.empty? %> + +

<%= HTML.escape(item.author) %> + <%- if author_verified %> <% end -%> +

+
+ <% else %> +

<%= HTML.escape(item.author) %> + <%- if author_verified %> <% end -%> +

+ <% end %> +
<% when Category %> <% else %> @@ -160,11 +168,19 @@
-
-

<%= HTML.escape(item.author) %> - <%- if author_verified %> <% end -%> -

-
+
+ <% if !item.ucid.to_s.empty? %> + +

<%= HTML.escape(item.author) %> + <%- if author_verified %> <% end -%> +

+
+ <% else %> +

<%= HTML.escape(item.author) %> + <%- if author_verified %> <% end -%> +

+ <% end %> +
<%= rendered "components/video-context-buttons" %>
diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index 56325cf7..0e72957e 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -822,9 +822,9 @@ module HelperExtractors end # Retrieves the ID required for querying the InnerTube browse endpoint. - # Raises when it's unable to do so + # Returns an empty string when it's unable to do so def self.get_browse_id(container) - return container.dig("navigationEndpoint", "browseEndpoint", "browseId").as_s + return container.dig?("navigationEndpoint", "browseEndpoint", "browseId").try &.as_s || "" end end From f1edb1d6bfbc30af46f6d3fa291d6d6fd7d66819 Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:49:32 -0400 Subject: [PATCH 2/2] fix related video author when id is empty --- src/invidious/views/watch.ecr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 07474896..1b020321 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -346,7 +346,7 @@ we're going to need to do it here in order to allow for translations.
- <% if rv["ucid"]? %> + <% if !rv["ucid"].empty? %> "><%= rv["author"]? %><% if rv["author_verified"]? == "true" %> <% end %> <% else %> <%= rv["author"]? %><% if rv["author_verified"]? == "true" %> <% end %>