From 0aaa3e6a08ae80f272ad260dc61213c8af83894b Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Sun, 26 Nov 2023 17:34:30 -0500 Subject: API: Parse channel's tags --- src/invidious/channels/about.cr | 16 ++++++++++++++-- src/invidious/routes/api/v1/channels.cr | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/invidious/channels/about.cr b/src/invidious/channels/about.cr index 8b60a728..b5a27667 100644 --- a/src/invidious/channels/about.cr +++ b/src/invidious/channels/about.cr @@ -14,6 +14,7 @@ record AboutChannel, is_family_friendly : Bool, allowed_regions : Array(String), tabs : Array(String), + tags : Array(String), verified : Bool def get_about_info(ucid, locale) : AboutChannel @@ -43,6 +44,8 @@ def get_about_info(ucid, locale) : AboutChannel auto_generated = true end + tags = [] of String + if auto_generated author = initdata["header"]["interactiveTabbedHeaderRenderer"]["title"]["simpleText"].as_s author_url = initdata["microformat"]["microformatDataRenderer"]["urlCanonical"].as_s @@ -52,7 +55,13 @@ def get_about_info(ucid, locale) : AboutChannel banners = initdata["header"]["interactiveTabbedHeaderRenderer"]?.try &.["banner"]?.try &.["thumbnails"]? banner = banners.try &.[-1]?.try &.["url"].as_s? - description_node = initdata["header"]["interactiveTabbedHeaderRenderer"]["description"] + description_base_node = initdata["header"]["interactiveTabbedHeaderRenderer"]["description"] + # some channels have the description in a simpleText + # ex: https://www.youtube.com/channel/UCQvWX73GQygcwXOTSf_VDVg/ + description_node = description_base_node.dig?("simpleText") || description_base_node + + tags = initdata.dig?("header", "interactiveTabbedHeaderRenderer", "badges") + .try &.as_a.map(&.["metadataBadgeRenderer"]["label"].as_s) || [] of String else author = initdata["metadata"]["channelMetadataRenderer"]["title"].as_s author_url = initdata["metadata"]["channelMetadataRenderer"]["channelUrl"].as_s @@ -70,6 +79,7 @@ def get_about_info(ucid, locale) : AboutChannel # end description_node = initdata["metadata"]["channelMetadataRenderer"]?.try &.["description"]? + tags = initdata.dig?("microformat", "microformatDataRenderer", "tags").try &.as_a.map(&.as_s) || [] of String end is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool @@ -131,7 +141,8 @@ def get_about_info(ucid, locale) : AboutChannel # ["description"]["simpleText"] and ["primaryLinks"][0]["title"]["simpleText"] auto_generated = ( (channel_about_meta["primaryLinks"]?.try &.size) == 1 && \ - extract_text(channel_about_meta.dig?("primaryLinks", 0, "title")) == "Auto-generated by YouTube" + extract_text(channel_about_meta.dig?("primaryLinks", 0, "title")) == "Auto-generated by YouTube" || + channel_about_meta.dig?("links", 0, "channelExternalLinkViewModel", "title", "content").try &.as_s == "Auto-generated by YouTube" ) end end @@ -155,6 +166,7 @@ def get_about_info(ucid, locale) : AboutChannel is_family_friendly: is_family_friendly, allowed_regions: allowed_regions, tabs: tab_names, + tags: tags, verified: author_verified || false, ) end diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr index 67018660..1d409c79 100644 --- a/src/invidious/routes/api/v1/channels.cr +++ b/src/invidious/routes/api/v1/channels.cr @@ -90,6 +90,7 @@ module Invidious::Routes::API::V1::Channels json.field "allowedRegions", channel.allowed_regions json.field "tabs", channel.tabs + json.field "tags", channel.tags json.field "authorVerified", channel.verified json.field "latestVideos" do -- cgit v1.2.3 c6fd&follow=1'>Collapse)Author 2021-10-20Clarify READMESiddharth Singh This was recently posted on Hacker News, and someone wrote that it wasn't clear enough that you'd be accessing the same content. Hopefully this commit fixes that. 2021-10-19Fix typo in "Toggle Wikipedia redirects" aria labelAlyssa Ross 2021-10-16Remove Onion v2 links ...xanoni ... because everything comes to an end 2021-08-15Fixed french typo in store.mdMonsieurBibo 2021-07-26Update messages.jsonElaborendum 2021-07-25Disable Wikiless redirects by default, add "New" tag (#232).v1.1.49SimonBrazell 2021-07-17add libreddit instancegit-bruh 2021-07-14removing invidious.fdn.frEmilien Devos 2021-07-12cleanupKotuklion 2021-07-12better GET processingKotuklion 2021-07-12check host instead of the whole href for occurence of wikipedia.orgKotuklion 2021-07-12left some unnecessary spaces here and thereKotuklion 2021-07-12fix minor typosKotuklion 2021-07-12add Wikiless supportKotuklion 2021-07-11Italian translation fixunbranched Title fix 2021-07-10Add redirect for Norwegian Google TranslateTim Hårek Andreassen Signed-off-by: Tim Hårek Andreassen <tim@harek.dev> 2021-07-10Bump version & update dependencies.v1.1.48SimonBrazell 2021-07-10Closes #242: remove "new" tag from SimplyTranslate.SimonBrazell 2021-06-16Fixes #238SimonBrazell 2021-06-16Redirect Twitter "video" subdomain & update dev dependencies.SimonBrazell 2021-06-16Fixed license linkGaurang Tandon 2021-06-16Added reddit.artemislena.euFantasyCookie17 2021-06-12Only append autoplay parameter if necessarybopol