From 814e8f14e235f7e05c29b41eeb1d12a3a3a24779 Mon Sep 17 00:00:00 2001 From: syeopite Date: Tue, 6 Apr 2021 03:41:07 -0700 Subject: [PATCH] Add support for verified badges on playlist results --- src/invidious/helpers/helpers.cr | 17 ++++++++++------- src/invidious/search.cr | 1 + src/invidious/views/components/item.ecr | 3 +++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 4ca7bf16..f97559ce 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -345,6 +345,7 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil, author_id_fa title: title, id: plid, author: author_fallback || "", + author_verified: false, ucid: author_id_fallback || "", video_count: video_count, videos: [] of SearchPlaylistVideo, @@ -360,6 +361,7 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil, author_id_fa author_info = i["shortBylineText"]?.try &.["runs"]?.try &.as_a?.try &.[0]? author = author_info.try &.["text"].as_s || author_fallback || "" author_id = author_info.try &.["navigationEndpoint"]?.try &.["browseEndpoint"]["browseId"].as_s || author_id_fallback || "" + author_verified = i["ownerBadges"]?.try &.as_a[0]["metadataBadgeRenderer"]?.try &.["style"]?.try &.to_s == "BADGE_STYLE_TYPE_VERIFIED" ? true : false || false videos = i["videos"]?.try &.as_a.map do |v| v = v["childVideoRenderer"] @@ -376,13 +378,14 @@ def extract_item(item : JSON::Any, author_fallback : String? = nil, author_id_fa # TODO: i["publishedTimeText"]? SearchPlaylist.new({ - title: title, - id: plid, - author: author, - ucid: author_id, - video_count: video_count, - videos: videos, - thumbnail: playlist_thumbnail, + title: title, + id: plid, + author: author, + author_verified: author_verified, + ucid: author_id, + video_count: video_count, + videos: videos, + thumbnail: playlist_thumbnail, }) elsif i = item["radioRenderer"]? # Mix # TODO diff --git a/src/invidious/search.cr b/src/invidious/search.cr index 6d680662..e41865f4 100644 --- a/src/invidious/search.cr +++ b/src/invidious/search.cr @@ -131,6 +131,7 @@ struct SearchPlaylist property title : String property id : String property author : String + property author_verified : Bool property ucid : String property video_count : Int32 property videos : Array(SearchPlaylistVideo) diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index cd22b1ea..1838d2f4 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -37,6 +37,9 @@

<%= item.author %> + <% if item.is_a?(SearchPlaylist) && item.author_verified %> + + <% end %>

<% when MixVideo %>