mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-02 18:58:29 +00:00
Channel: display playlists for autogenerated channels
This commit is contained in:
parent
c5b87e3b5e
commit
d046423d67
@ -25,6 +25,8 @@
|
|||||||
"newest": "newest",
|
"newest": "newest",
|
||||||
"oldest": "oldest",
|
"oldest": "oldest",
|
||||||
"popular": "popular",
|
"popular": "popular",
|
||||||
|
"albums_and_singles": "Albums & Singles",
|
||||||
|
"created_playlists": "Created Playlists",
|
||||||
"last": "last",
|
"last": "last",
|
||||||
"Next page": "Next page",
|
"Next page": "Next page",
|
||||||
"Previous page": "Previous page",
|
"Previous page": "Previous page",
|
||||||
|
@ -14,6 +14,7 @@ record AboutChannel,
|
|||||||
is_family_friendly : Bool,
|
is_family_friendly : Bool,
|
||||||
allowed_regions : Array(String),
|
allowed_regions : Array(String),
|
||||||
tabs : Array(String),
|
tabs : Array(String),
|
||||||
|
tags : Array(String),
|
||||||
verified : Bool
|
verified : Bool
|
||||||
|
|
||||||
def get_about_info(ucid, locale) : AboutChannel
|
def get_about_info(ucid, locale) : AboutChannel
|
||||||
@ -43,6 +44,7 @@ def get_about_info(ucid, locale) : AboutChannel
|
|||||||
auto_generated = true
|
auto_generated = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tags = [] of String
|
||||||
if auto_generated
|
if auto_generated
|
||||||
author = initdata["header"]["interactiveTabbedHeaderRenderer"]["title"]["simpleText"].as_s
|
author = initdata["header"]["interactiveTabbedHeaderRenderer"]["title"]["simpleText"].as_s
|
||||||
author_url = initdata["microformat"]["microformatDataRenderer"]["urlCanonical"].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"]?
|
banners = initdata["header"]["interactiveTabbedHeaderRenderer"]?.try &.["banner"]?.try &.["thumbnails"]?
|
||||||
banner = banners.try &.[-1]?.try &.["url"].as_s?
|
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
|
else
|
||||||
author = initdata["metadata"]["channelMetadataRenderer"]["title"].as_s
|
author = initdata["metadata"]["channelMetadataRenderer"]["title"].as_s
|
||||||
author_url = initdata["metadata"]["channelMetadataRenderer"]["channelUrl"].as_s
|
author_url = initdata["metadata"]["channelMetadataRenderer"]["channelUrl"].as_s
|
||||||
@ -70,6 +77,7 @@ def get_about_info(ucid, locale) : AboutChannel
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
description_node = initdata["metadata"]["channelMetadataRenderer"]?.try &.["description"]?
|
description_node = initdata["metadata"]["channelMetadataRenderer"]?.try &.["description"]?
|
||||||
|
tags = initdata.dig?("microformat", "microformatDataRenderer", "tags").try &.as_a.map(&.as_s) || [] of String
|
||||||
end
|
end
|
||||||
|
|
||||||
is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool
|
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,
|
is_family_friendly: is_family_friendly,
|
||||||
allowed_regions: allowed_regions,
|
allowed_regions: allowed_regions,
|
||||||
tabs: tab_names,
|
tabs: tab_names,
|
||||||
|
tags: tags,
|
||||||
verified: author_verified || false,
|
verified: author_verified || false,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -19,6 +19,10 @@ def fetch_channel_playlists(ucid, author, continuation, sort_by)
|
|||||||
# Formerly "&sort=dd"
|
# Formerly "&sort=dd"
|
||||||
# {"2:string": "playlists", "3:varint": 3, "4:varint": 1, "6:varint": 1}
|
# {"2:string": "playlists", "3:varint": 3, "4:varint": 1, "6:varint": 1}
|
||||||
"EglwbGF5bGlzdHMYAyABMAE%3D"
|
"EglwbGF5bGlzdHMYAyABMAE%3D"
|
||||||
|
when "albums_and_singles"
|
||||||
|
"EglwbGF5bGlzdHMgMnDNg9T2lpLClfUB"
|
||||||
|
when "created_playlists"
|
||||||
|
"EglwbGF5bGlzdHMgAQ%3D%3D"
|
||||||
end
|
end
|
||||||
|
|
||||||
initial_data = YoutubeAPI.browse(ucid, params: params || "")
|
initial_data = YoutubeAPI.browse(ucid, params: params || "")
|
||||||
|
@ -17,9 +17,6 @@ module Invidious::Frontend::ChannelPage
|
|||||||
base_url = "/channel/#{channel.ucid}"
|
base_url = "/channel/#{channel.ucid}"
|
||||||
|
|
||||||
TabsAvailable.each do |tab|
|
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
|
tab_name = tab.to_s.downcase
|
||||||
|
|
||||||
if channel.tabs.includes? tab_name
|
if channel.tabs.includes? tab_name
|
||||||
|
@ -90,6 +90,7 @@ module Invidious::Routes::API::V1::Channels
|
|||||||
|
|
||||||
json.field "allowedRegions", channel.allowed_regions
|
json.field "allowedRegions", channel.allowed_regions
|
||||||
json.field "tabs", channel.tabs
|
json.field "tabs", channel.tabs
|
||||||
|
json.field "tags", channel.tags
|
||||||
json.field "authorVerified", channel.verified
|
json.field "authorVerified", channel.verified
|
||||||
|
|
||||||
json.field "latestVideos" do
|
json.field "latestVideos" do
|
||||||
|
@ -100,15 +100,16 @@ module Invidious::Routes::Channels
|
|||||||
|
|
||||||
locale, user, subscriptions, continuation, ucid, channel = data
|
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
|
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
|
end
|
||||||
|
|
||||||
items, next_continuation = fetch_channel_playlists(
|
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)
|
items = items.select(SearchPlaylist)
|
||||||
|
Loading…
Reference in New Issue
Block a user