diff --git a/config/config.example.yml b/config/config.example.yml index 2b99345b..b6db3bb2 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -712,12 +712,12 @@ default_user_preferences: ## when the user is logged in. ## ## Accepted values: A list of strings - ## Each entry can be one of: "Popular", "Trending", + ## Each entry can be one of: "Popular", ## "Subscriptions", "Playlists" ## - ## Default: ["Popular", "Trending", "Subscriptions", "Playlists"] (show all feeds) + ## Default: ["Popular", "Subscriptions", "Playlists"] (show all feeds) ## - #feed_menu: ["Popular", "Trending", "Subscriptions", "Playlists"] + #feed_menu: ["Popular", "Subscriptions", "Playlists"] ## ## Default feed to display on the home page. @@ -725,7 +725,7 @@ default_user_preferences: ## Note: setting this option to "Popular" has no ## effect when 'popular_enabled' is set to false. ## - ## Accepted values: Popular, Trending, Subscriptions, Playlists, + ## Accepted values: Popular, Subscriptions, Playlists, ## Default: Popular ## #default_home: Popular diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index b3060acf..3635c1ea 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -9,7 +9,6 @@ require "../src/invidious/videos/caption" require "../src/invidious/videos" require "../src/invidious/playlists" require "../src/invidious/search/ctoken" -require "../src/invidious/trending" require "spectator" Spectator.configure do |config| diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 92c510d0..7db8c2d8 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -38,7 +38,7 @@ struct ConfigPreferences property quality : String = "dash" property quality_dash : String = "auto" property default_home : String? = "Popular" - property feed_menu : Array(String) = ["Popular", "Trending", "Subscriptions", "Playlists"] + property feed_menu : Array(String) = ["Popular", "Subscriptions", "Playlists"] property automatic_instance_redirect : Bool = false property region : String = "US" property related_videos : Bool = true diff --git a/src/invidious/routes/api/v1/feeds.cr b/src/invidious/routes/api/v1/feeds.cr index fea2993c..61e46391 100644 --- a/src/invidious/routes/api/v1/feeds.cr +++ b/src/invidious/routes/api/v1/feeds.cr @@ -1,29 +1,4 @@ module Invidious::Routes::API::V1::Feeds - def self.trending(env) - locale = env.get("preferences").as(Preferences).locale - - env.response.content_type = "application/json" - - region = env.params.query["region"]? - trending_type = env.params.query["type"]? - - begin - trending, plid = fetch_trending(trending_type, region, locale) - rescue ex - return error_json(500, ex) - end - - videos = JSON.build do |json| - json.array do - trending.each do |video| - video.to_json(locale, json) - end - end - end - - videos - end - def self.popular(env) locale = env.get("preferences").as(Preferences).locale diff --git a/src/invidious/routes/feeds.cr b/src/invidious/routes/feeds.cr index 070c96eb..129381f5 100644 --- a/src/invidious/routes/feeds.cr +++ b/src/invidious/routes/feeds.cr @@ -42,24 +42,6 @@ module Invidious::Routes::Feeds end end - def self.trending(env) - locale = env.get("preferences").as(Preferences).locale - - trending_type = env.params.query["type"]? - trending_type ||= "Default" - - region = env.params.query["region"]? - region ||= env.get("preferences").as(Preferences).region - - begin - trending, plid = fetch_trending(trending_type, region, locale) - rescue ex - return error_template(500, ex) - end - - templated "feeds/trending" - end - def self.subscriptions(env) locale = env.get("preferences").as(Preferences).locale diff --git a/src/invidious/routes/misc.cr b/src/invidious/routes/misc.cr index 0b868755..d76b09a7 100644 --- a/src/invidious/routes/misc.cr +++ b/src/invidious/routes/misc.cr @@ -9,8 +9,6 @@ module Invidious::Routes::Misc case preferences.default_home when "Popular" env.redirect "/feed/popular" - when "Trending" - env.redirect "/feed/trending" when "Subscriptions" if user env.redirect "/feed/subscriptions" diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index 9936e523..f5b4a9d3 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -103,7 +103,7 @@ module Invidious::Routes::PreferencesRoute default_home = env.params.body["default_home"]?.try &.as(String) || CONFIG.default_user_preferences.default_home feed_menu = [] of String - 4.times do |index| + 3.times do |index| option = env.params.body["feed_menu[#{index}]"]?.try &.as(String) || "" if !option.empty? feed_menu << option @@ -194,7 +194,7 @@ module Invidious::Routes::PreferencesRoute CONFIG.default_user_preferences.default_home = env.params.body["admin_default_home"]?.try &.as(String) || CONFIG.default_user_preferences.default_home admin_feed_menu = [] of String - 4.times do |index| + 3.times do |index| option = env.params.body["admin_feed_menu[#{index}]"]?.try &.as(String) || "" if !option.empty? admin_feed_menu << option diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index a51bb4b6..98d999b4 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -98,7 +98,6 @@ module Invidious::Routing get "/view_all_playlists", Routes::Feeds, :view_all_playlists_redirect get "/feed/playlists", Routes::Feeds, :playlists get "/feed/popular", Routes::Feeds, :popular - get "/feed/trending", Routes::Feeds, :trending get "/feed/subscriptions", Routes::Feeds, :subscriptions get "/feed/history", Routes::Feeds, :history @@ -249,7 +248,6 @@ module Invidious::Routing get "/api/v1/transcripts/:id", {{namespace}}::Videos, :transcripts # Feeds - get "/api/v1/trending", {{namespace}}::Feeds, :trending get "/api/v1/popular", {{namespace}}::Feeds, :popular # Channels diff --git a/src/invidious/trending.cr b/src/invidious/trending.cr deleted file mode 100644 index e289ed5b..00000000 --- a/src/invidious/trending.cr +++ /dev/null @@ -1,47 +0,0 @@ -def fetch_trending(trending_type, region, locale) - region ||= "US" - region = region.upcase - - plid = nil - - browse_id = "FEtrending" - - case trending_type.try &.downcase - when "music" - params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D" - when "gaming" - params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D" - when "movies" - params = "4gIKGgh0cmFpbGVycw%3D%3D" - when "livestreams" - browse_id = "UC4R8DWoMoI7CAwX8_LjQHig" - params = "EgdsaXZldGFikgEDCKEK" - else # Default - params = "" - end - - client_config = YoutubeAPI::ClientConfig.new(region: region) - initial_data = YoutubeAPI.browse(browse_id, params: params, client_config: client_config) - - items, _ = extract_items(initial_data) - - extracted = [] of SearchItem - - deduplicate = items.size > 1 - - items.each do |itm| - if itm.is_a?(Category) - # Ignore the smaller categories, as they generally contain a sponsored - # channel, which brings a lot of noise on the trending page. - # See: https://github.com/iv-org/invidious/issues/2989 - next if (itm.contents.size < 24 && deduplicate) - - extracted.concat itm.contents.select(SearchItem) - else - extracted << itm - end - end - - # Deduplicate items before returning results - return extracted.select(SearchVideo | ProblematicTimelineItem).uniq!(&.id), plid -end diff --git a/src/invidious/views/components/feed_menu.ecr b/src/invidious/views/components/feed_menu.ecr index 3dbeaf37..425b8b7a 100644 --- a/src/invidious/views/components/feed_menu.ecr +++ b/src/invidious/views/components/feed_menu.ecr @@ -1,5 +1,12 @@
<% feed_menu = env.get("preferences").as(Preferences).feed_menu.dup %> + <% + # Remove the Trending page from the menu for users with the Trending + # item inside their PREFS cookie or in their user preferences saved + # in the database (if registered user) + # https://github.com/iv-org/invidious/issues/5397 + %> + <% feed_menu.reject! {|item| "Trending" == item} %> <% if !env.get?("user") %> <% feed_menu.reject! {|item| {"Subscriptions", "Playlists"}.includes? item} %> <% end %> diff --git a/src/invidious/views/feeds/trending.ecr b/src/invidious/views/feeds/trending.ecr deleted file mode 100644 index 69483f30..00000000 --- a/src/invidious/views/feeds/trending.ecr +++ /dev/null @@ -1,49 +0,0 @@ -<% content_for "header" do %> -"> - - <% if env.get("preferences").as(Preferences).default_home != "Trending" %> - <%= translate(locale, "Trending") %> - Invidious - <% else %> - Invidious - <% end %> - -<% end %> - -<%= rendered "components/feed_menu" %> - -
- -
-
- <% {"Default", "Music", "Gaming", "Movies", "Livestreams"}.each do |option| %> -
- <% if trending_type == option %> - <%= translate(locale, option) %> - <% else %> - - <%= translate(locale, option) %> - - <% end %> -
- <% end %> -
-
-
- -
-
-
- -
-<% trending.each do |item| %> - <%= rendered "components/item" %> -<% end %> -
- - diff --git a/src/invidious/views/user/preferences.ecr b/src/invidious/views/user/preferences.ecr index 23cb89f6..63fc60a9 100644 --- a/src/invidious/views/user/preferences.ecr +++ b/src/invidious/views/user/preferences.ecr @@ -183,9 +183,9 @@
<% if env.get?("user") %> - <% feed_options = {"", "Popular", "Trending", "Subscriptions", "Playlists"} %> + <% feed_options = {"", "Popular", "Subscriptions", "Playlists"} %> <% else %> - <% feed_options = {"", "Popular", "Trending"} %> + <% feed_options = {"", "Popular"} %> <% end %>