update detection of auto_generated channels

This commit is contained in:
ChunkyProgrammer 2023-08-30 00:12:53 -04:00
parent df15cf91ff
commit d61acbed01
2 changed files with 4 additions and 17 deletions

View File

@ -139,8 +139,9 @@ def get_about_info(ucid, locale) : AboutChannel
# For auto-generated channels, channel_about_meta only has
# ["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"
((channel_about_meta["primaryLinks"]?.try &.size) == 1 && \
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

View File

@ -20,21 +20,7 @@ module Invidious::Routes::Channels
sort_by = env.params.query["sort_by"]?.try &.downcase
if channel.auto_generated
sort_options = {"last", "oldest", "newest"}
items, next_continuation = fetch_channel_playlists(
channel.ucid, channel.author, continuation, (sort_by || "last")
)
items.uniq! do |item|
if item.responds_to?(:title)
item.title
elsif item.responds_to?(:author)
item.author
end
end
items = items.select(SearchPlaylist)
items.each(&.author = "")
return env.redirect "/channel/#{ucid}/playlists"
else
sort_options = {"newest", "oldest", "popular"}