From 50d793e49b8e366f7b6c4bb39620035eb2ae2f09 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Thu, 12 Sep 2019 13:11:21 -0400 Subject: [PATCH] Hide video count for auto-generated channels --- src/invidious/helpers/helpers.cr | 6 +++--- src/invidious/search.cr | 3 +++ src/invidious/views/components/item.ecr | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index bd9d0b4e..43ccf0c5 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -424,15 +424,15 @@ def extract_items(nodeset, ucid = nil, author_name = nil) subscriber_count ||= 0 video_count = node.xpath_node(%q(.//ul[@class="yt-lockup-meta-info"]/li)).try &.content.split(" ")[0].gsub(/\D/, "").to_i? - video_count ||= 0 items << SearchChannel.new( author: author, ucid: ucid, author_thumbnail: author_thumbnail, subscriber_count: subscriber_count, - video_count: video_count, - description_html: description_html + video_count: video_count || 0, + description_html: description_html, + auto_generated: video_count ? false : true, ) else id = id.lchop("/watch?v=") diff --git a/src/invidious/search.cr b/src/invidious/search.cr index a55bb216..71e1f737 100644 --- a/src/invidious/search.cr +++ b/src/invidious/search.cr @@ -185,8 +185,10 @@ struct SearchChannel end end + json.field "autoGenerated", self.auto_generated json.field "subCount", self.subscriber_count json.field "videoCount", self.video_count + json.field "description", html_to_content(self.description_html) json.field "descriptionHtml", self.description_html end @@ -209,6 +211,7 @@ struct SearchChannel subscriber_count: Int32, video_count: Int32, description_html: String, + auto_generated: Bool, }) end diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index 71ae70df..c722d0bc 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -11,7 +11,7 @@

<%= item.author %>

<%= translate(locale, "`x` subscribers", number_with_separator(item.subscriber_count)) %>

-

<%= translate(locale, "`x` videos", number_with_separator(item.video_count)) %>

+ <% if !item.auto_generated %>

<%= translate(locale, "`x` videos", number_with_separator(item.video_count)) %>

<% end %>
<%= item.description_html %>
<% when SearchPlaylist %> <% if item.id.starts_with? "RD" %>