From aa8f15f795787113e56473f8e8fd606749a14bdd Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 8 May 2021 20:07:07 -0700 Subject: [PATCH] Add description_html field to Category --- src/invidious/channels.cr | 3 +++ src/invidious/helpers/extractors.cr | 4 ++++ src/invidious/helpers/invidiousitems.cr | 1 + src/invidious/views/channel/home.ecr | 0 4 files changed, 8 insertions(+) create mode 100644 src/invidious/views/channel/home.ecr diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr index 082fc587..bdfe5aa6 100644 --- a/src/invidious/channels.cr +++ b/src/invidious/channels.cr @@ -391,6 +391,7 @@ def fetch_channel_featured_channels(ucid, tab_data, view = nil, shelf_id = nil, return [Category.new({ title: query_title.not_nil!, # If continuation contents is requested then the query_title has to be passed along. contents: items, + description_html: "", browse_endpoint_data: nil, badges: nil, auxiliary_data: auxiliary_data, @@ -435,6 +436,7 @@ def fetch_channel_featured_channels(ucid, tab_data, view = nil, shelf_id = nil, category_array << Category.new({ title: category.title.empty? ? fallback_title : category.title, contents: category.contents, + description_html: category.description_html, browse_endpoint_data: nil, badges: nil, auxiliary_data: category.auxiliary_data, @@ -446,6 +448,7 @@ def fetch_channel_featured_channels(ucid, tab_data, view = nil, shelf_id = nil, category_array << Category.new({ title: fallback_title, contents: items, + description_html: "", browse_endpoint_data: nil, badges: nil, auxiliary_data: auxiliary_data, diff --git a/src/invidious/helpers/extractors.cr b/src/invidious/helpers/extractors.cr index 5d9844cc..430bb41c 100644 --- a/src/invidious/helpers/extractors.cr +++ b/src/invidious/helpers/extractors.cr @@ -258,6 +258,9 @@ private class CategoryParser < ItemParser badges << {badge["style"].as_s, badge["label"].as_s} end + # Category description + description_html = item_contents["subtitle"]?.try { |desc| parse_content(desc) } || "" + # Content parsing contents = [] of SearchItem @@ -280,6 +283,7 @@ private class CategoryParser < ItemParser Category.new({ title: title, contents: contents, + description_html: description_html, browse_endpoint_data: browse_endpoint_data, badges: badges, auxiliary_data: auxiliary_data, diff --git a/src/invidious/helpers/invidiousitems.cr b/src/invidious/helpers/invidiousitems.cr index 1964be7e..83bd5320 100644 --- a/src/invidious/helpers/invidiousitems.cr +++ b/src/invidious/helpers/invidiousitems.cr @@ -234,6 +234,7 @@ class Category property title : String property contents : Array(SearchItem) property browse_endpoint_data : String? + property description_html : String property badges : Array(Tuple(String, String))? # Data unique to only specific types of categories. diff --git a/src/invidious/views/channel/home.ecr b/src/invidious/views/channel/home.ecr new file mode 100644 index 00000000..e69de29b