Skip to content

Commit 1fee636

Browse files
committed
Added verification badge to video player and error with related_videos
1 parent 154bca4 commit 1fee636

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/invidious/channels/about.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_about_info(ucid, locale) : AboutChannel
6363
author_thumbnail = initdata["metadata"]["channelMetadataRenderer"]["avatar"]["thumbnails"][0]["url"].as_s
6464

6565
ucid = initdata["metadata"]["channelMetadataRenderer"]["externalId"].as_s
66-
66+
6767
# Raises a KeyError on failure.
6868
banners = initdata["header"]["c4TabbedHeaderRenderer"]?.try &.["banner"]?.try &.["thumbnails"]?
6969
banner = banners.try &.[-1]?.try &.["url"].as_s?
@@ -73,7 +73,7 @@ def get_about_info(ucid, locale) : AboutChannel
7373
# end
7474
badges = initdata["header"]["c4TabbedHeaderRenderer"]?.try &.["badges"]?
7575
if !badges.nil?
76-
verified=true
76+
verified = true
7777
end
7878
description = initdata["metadata"]["channelMetadataRenderer"]?.try &.["description"]?.try &.as_s? || ""
7979
description_html = HTML.escape(description)

src/invidious/videos.cr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ struct Video
570570
info["authorThumbnail"]?.try &.as_s || ""
571571
end
572572

573+
def author_verified : Bool
574+
info["authorVerified"].as_bool
575+
end
576+
573577
def sub_count_text : String
574578
info["subCountText"]?.try &.as_s || "-"
575579
end
@@ -822,6 +826,7 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
822826
.try &.dig?("runs", 0)
823827

824828
author = channel_info.try &.dig?("text")
829+
authorVerified = channel_info.try &.dig?("ownerBadges") != nil
825830
ucid = channel_info.try { |ci| HelperExtractors.get_browse_id(ci) }
826831

827832
# "4,088,033 views", only available on compact renderer
@@ -845,6 +850,7 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
845850
"length_seconds" => JSON::Any.new(length || "0"),
846851
"view_count" => JSON::Any.new(view_count || "0"),
847852
"short_view_count" => JSON::Any.new(short_view_count || "0"),
853+
"author_verified" => JSON::Any.new(authorVerified),
848854
}
849855
end
850856

@@ -1037,7 +1043,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
10371043

10381044
author_info = video_secondary_renderer.try &.dig?("owner", "videoOwnerRenderer")
10391045
author_thumbnail = author_info.try &.dig?("thumbnail", "thumbnails", 0, "url")
1040-
1046+
params["authorVerified"] = JSON::Any.new(author_info.try &.["badges"]? != nil)
10411047
params["authorThumbnail"] = JSON::Any.new(author_thumbnail.try &.as_s || "")
10421048

10431049
params["subCountText"] = JSON::Any.new(author_info.try &.["subscriberCountText"]?

src/invidious/views/watch.ecr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ we're going to need to do it here in order to allow for translations.
240240
<% if !video.author_thumbnail.empty? %>
241241
<img src="/ggpht<%= URI.parse(video.author_thumbnail).request_target %>">
242242
<% end %>
243-
<span id="channel-name"><%= author %></span>
243+
<span id="channel-name"><%= author %><% if video.author_verified %><i class="icon ion ion-md-checkmark-circle"></i><% end %></span>
244244
</div>
245245
</a>
246246

0 commit comments

Comments
 (0)