Skip to content

Commit 864893f

Browse files
Channels: parse pronouns and display them on channel page (#5617)
1 parent ecbc21b commit 864893f

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

assets/css/default.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ body {
7575
height: auto;
7676
}
7777

78+
.channel-profile > .channel-name-pronouns {
79+
display: inline-block;
80+
}
81+
82+
.channel-profile > .channel-name-pronouns > .channel-pronouns {
83+
font-style: italic;
84+
font-size: .8em;
85+
font-weight: lighter;
86+
}
87+
7888
body a.channel-owner {
7989
background-color: #008bec;
8090
color: #fff;
@@ -406,7 +416,12 @@ input[type="search"]::-webkit-search-cancel-button {
406416

407417
p.channel-name { margin: 0; overflow-wrap: anywhere;}
408418
p.video-data { margin: 0; font-weight: bold; font-size: 80%; }
409-
.channel-profile > .channel-name { overflow-wrap: anywhere;}
419+
420+
.channel-profile > .channel-name,
421+
.channel-profile > .channel-name-pronouns > .channel-name
422+
{
423+
overflow-wrap: anywhere;
424+
}
410425

411426

412427
/*

src/invidious/channels/about.cr

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ record AboutChannel,
1212
sub_count : Int32,
1313
joined : Time,
1414
is_family_friendly : Bool,
15+
pronouns : String?,
1516
allowed_regions : Array(String),
1617
tabs : Array(String),
1718
tags : Array(String),
@@ -160,14 +161,21 @@ def get_about_info(ucid, locale) : AboutChannel
160161
end
161162

162163
sub_count = 0
164+
pronouns = nil
163165

164166
if (metadata_rows = initdata.dig?("header", "pageHeaderRenderer", "content", "pageHeaderViewModel", "metadata", "contentMetadataViewModel", "metadataRows").try &.as_a)
165167
metadata_rows.each do |row|
166-
metadata_part = row.dig?("metadataParts").try &.as_a.find { |i| i.dig?("text", "content").try &.as_s.includes?("subscribers") }
167-
if !metadata_part.nil?
168-
sub_count = short_text_to_number(metadata_part.dig("text", "content").as_s.split(" ")[0]).to_i32
168+
subscribe_metadata_part = row.dig?("metadataParts").try &.as_a.find { |i| i.dig?("text", "content").try &.as_s.includes?("subscribers") }
169+
if !subscribe_metadata_part.nil?
170+
sub_count = short_text_to_number(subscribe_metadata_part.dig("text", "content").as_s.split(" ")[0]).to_i32
169171
end
170-
break if sub_count != 0
172+
173+
pronoun_metadata_part = row.dig?("metadataParts").try &.as_a.find { |i| i.dig?("tooltip").try &.as_s.includes?("Pronouns") }
174+
if !pronoun_metadata_part.nil?
175+
pronouns = pronoun_metadata_part.dig("text", "content").as_s
176+
end
177+
178+
break if sub_count != 0 && !pronouns.nil?
171179
end
172180
end
173181

@@ -184,6 +192,7 @@ def get_about_info(ucid, locale) : AboutChannel
184192
sub_count: sub_count,
185193
joined: joined,
186194
is_family_friendly: is_family_friendly,
195+
pronouns: pronouns,
187196
allowed_regions: allowed_regions,
188197
tabs: tab_names,
189198
tags: tags,

src/invidious/routes/api/v1/channels.cr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ module Invidious::Routes::API::V1::Channels
104104
json.field "tabs", channel.tabs
105105
json.field "tags", channel.tags
106106
json.field "authorVerified", channel.verified
107+
json.field "pronouns", channel.pronouns
107108

108109
json.field "latestVideos" do
109110
json.array do

src/invidious/views/components/channel_info.ecr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
<div class="pure-u-1-2 flex-left flexible">
1313
<div class="channel-profile">
1414
<img src="/ggpht<%= channel_profile_pic %>" alt="" />
15-
<span class="channel-name"><%= author %></span><% if !channel.verified.nil? && channel.verified %>&nbsp;<i class="icon ion ion-md-checkmark-circle"></i><% end %>
15+
<div class="channel-name-pronouns">
16+
<span class="channel-name"><%= author %></span><% if !channel.verified.nil? && channel.verified %>&nbsp;<i class="icon ion ion-md-checkmark-circle"></i><% end %>
17+
<% if !channel.pronouns.nil? %><br /><span class="channel-pronouns"><%= channel.pronouns %></span><% end %>
18+
</div>
1619
</div>
1720
</div>
1821

0 commit comments

Comments
 (0)