From a2578ac6b4a3ab370e2d1d483539ce9d32c272ca Mon Sep 17 00:00:00 2001 From: jonas-w Date: Fri, 4 Feb 2022 17:55:22 +0100 Subject: [PATCH] Added Verified Badge to related videos --- src/invidious/videos.cr | 8 ++++++-- src/invidious/views/watch.ecr | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index a5ecdeea..69468b5e 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -826,7 +826,11 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)? .try &.dig?("runs", 0) author = channel_info.try &.dig?("text") - authorVerified = channel_info.try &.dig?("ownerBadges") != nil + author_verified_badge = related["ownerBadges"]?.try do |badges_array| + badges_array.as_a.find(&.dig("metadataBadgeRenderer", "tooltip").as_s.== "Verified") + end + + author_verified = (author_verified_badge && author_verified_badge.size > 0).to_s ucid = channel_info.try { |ci| HelperExtractors.get_browse_id(ci) } # "4,088,033 views", only available on compact renderer @@ -850,7 +854,7 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)? "length_seconds" => JSON::Any.new(length || "0"), "view_count" => JSON::Any.new(view_count || "0"), "short_view_count" => JSON::Any.new(short_view_count || "0"), - "author_verified" => JSON::Any.new(authorVerified), + "author_verified" => JSON::Any.new(author_verified), } end diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 8422fce0..496ceddc 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -314,9 +314,9 @@ we're going to need to do it here in order to allow for translations.
<% if rv["ucid"]? %> - "><%= rv["author"]? %> + "><%= rv["author"]? %><% if rv["author_verified"].== "true" %><% end %> <% else %> - <%= rv["author"]? %> + <%= rv["author"]? %><% if rv["author_verified"].== "true" %><% end %> <% end %>