mirror of
https://github.com/iv-org/invidious.git
synced 2025-04-19 23:25:52 -04:00
Channel: display playlists for autogenerated channels
This commit is contained in:
parent
c5b87e3b5e
commit
d046423d67
@ -25,6 +25,8 @@
|
||||
"newest": "newest",
|
||||
"oldest": "oldest",
|
||||
"popular": "popular",
|
||||
"albums_and_singles": "Albums & Singles",
|
||||
"created_playlists": "Created Playlists",
|
||||
"last": "last",
|
||||
"Next page": "Next page",
|
||||
"Previous page": "Previous page",
|
||||
|
@ -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,7 @@ 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 +54,12 @@ 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 +77,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
|
||||
@ -155,6 +163,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
|
||||
|
@ -19,6 +19,10 @@ def fetch_channel_playlists(ucid, author, continuation, sort_by)
|
||||
# Formerly "&sort=dd"
|
||||
# {"2:string": "playlists", "3:varint": 3, "4:varint": 1, "6:varint": 1}
|
||||
"EglwbGF5bGlzdHMYAyABMAE%3D"
|
||||
when "albums_and_singles"
|
||||
"EglwbGF5bGlzdHMgMnDNg9T2lpLClfUB"
|
||||
when "created_playlists"
|
||||
"EglwbGF5bGlzdHMgAQ%3D%3D"
|
||||
end
|
||||
|
||||
initial_data = YoutubeAPI.browse(ucid, params: params || "")
|
||||
|
@ -17,9 +17,6 @@ module Invidious::Frontend::ChannelPage
|
||||
base_url = "/channel/#{channel.ucid}"
|
||||
|
||||
TabsAvailable.each do |tab|
|
||||
# Ignore playlists, as it is not supported for auto-generated channels yet
|
||||
next if (tab.playlists? && channel.auto_generated)
|
||||
|
||||
tab_name = tab.to_s.downcase
|
||||
|
||||
if channel.tabs.includes? tab_name
|
||||
|
@ -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
|
||||
|
@ -100,15 +100,16 @@ module Invidious::Routes::Channels
|
||||
|
||||
locale, user, subscriptions, continuation, ucid, channel = data
|
||||
|
||||
sort_options = {"last", "oldest", "newest"}
|
||||
sort_by = env.params.query["sort_by"]?.try &.downcase
|
||||
|
||||
if channel.auto_generated
|
||||
return env.redirect "/channel/#{channel.ucid}"
|
||||
sort_options = {"albums_and_singles", "created_playlists"}
|
||||
sort_by = env.params.query["sort_by"]?.try &.downcase || sort_options[0]
|
||||
else
|
||||
sort_options = {"last", "oldest", "newest"}
|
||||
sort_by = env.params.query["sort_by"]?.try &.downcase || sort_options[0]
|
||||
end
|
||||
|
||||
items, next_continuation = fetch_channel_playlists(
|
||||
channel.ucid, channel.author, continuation, (sort_by || "last")
|
||||
channel.ucid, channel.author, continuation, (sort_by)
|
||||
)
|
||||
|
||||
items = items.select(SearchPlaylist)
|
||||
|
Loading…
x
Reference in New Issue
Block a user