Add verified badge to channel on watch page

This commit is contained in:
syeopite 2021-04-07 04:39:37 -07:00
parent 1ecea1ce33
commit 1b4a8ecbcb
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82
3 changed files with 14 additions and 2 deletions

View File

@ -494,6 +494,10 @@ struct Video
info["videoDetails"]["author"]?.try &.as_s || ""
end
def author_verified
return info["authorVerified"]
end
def length_seconds : Int32
info["microformat"]?.try &.["playerMicroformatRenderer"]?.try &.["lengthSeconds"]?.try &.as_s.to_i ||
info["videoDetails"]["lengthSeconds"]?.try &.as_s.to_i || 0
@ -906,6 +910,10 @@ def extract_polymer_config(body)
author_info = primary_results.try &.as_a.select { |object| object["videoSecondaryInfoRenderer"]? }[0]?
.try &.["videoSecondaryInfoRenderer"]?.try &.["owner"]?.try &.["videoOwnerRenderer"]?
params["authorVerified"] = JSON::Any.new(author_info.try &.["badges"]?
.try &.[0]["metadataBadgeRenderer"]?.try &.["style"]?
.try &.to_s == "BADGE_STYLE_TYPE_VERIFIED" ? true : false || false)
params["authorThumbnail"] = JSON::Any.new(author_info.try &.["thumbnail"]?
.try &.["thumbnails"]?.try &.as_a[0]?.try &.["url"]?
.try &.as_s || "")

View File

@ -206,7 +206,7 @@
<div class="pure-u-1 <% if params.related_videos || plid %>pure-u-lg-3-5<% else %>pure-u-md-4-5<% end %>">
<div class="h-box">
<a href="/channel/<%= video.ucid %>" style="display:block;width:fit-content;width:-moz-fit-content">
<div class="channel-profile">
<div class="channel-profile" style="display: inline;">
<% if !video.author_thumbnail.empty? %>
<img src="/ggpht<%= URI.parse(video.author_thumbnail).request_target %>">
<% end %>
@ -214,6 +214,10 @@
</div>
</a>
<% if video.author_verified %>
<i class="channel_badge icon ion-md-checkmark-circle"></i>
<% end %>
<% ucid = video.ucid %>
<% author = video.author %>
<% sub_count_text = video.sub_count_text %>