Completely remove Trending page from Invidious

This commit is contained in:
Fijxu 2025-11-18 11:30:36 -03:00
parent c250b9c0b1
commit d8ef37d5dd
No known key found for this signature in database
GPG Key ID: 32C1DDF333EDA6A4
12 changed files with 10 additions and 153 deletions

View File

@ -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, <none>
## Accepted values: Popular, Subscriptions, Playlists, <none>
## Default: Popular
##
#default_home: Popular

View File

@ -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|

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,5 +1,6 @@
<div class="feed-menu">
<% feed_menu = env.get("preferences").as(Preferences).feed_menu.dup %>
<% feed_menu.reject! {|item| "Trending" == item} %>
<% if !env.get?("user") %>
<% feed_menu.reject! {|item| {"Subscriptions", "Playlists"}.includes? item} %>
<% end %>

View File

@ -1,49 +0,0 @@
<% content_for "header" do %>
<meta name="description" content="<%= translate(locale, "An alternative front-end to YouTube") %>">
<title>
<% if env.get("preferences").as(Preferences).default_home != "Trending" %>
<%= translate(locale, "Trending") %> - Invidious
<% else %>
Invidious
<% end %>
</title>
<% end %>
<%= rendered "components/feed_menu" %>
<div class="pure-g h-box">
<div style="align-self:flex-end" class="pure-u-2-3">
<% if plid %>
<a href="/playlist?list=<%= plid %>">
<%= translate(locale, "View as playlist") %>
</a>
<% end %>
</div>
<div class="pure-u-1-3">
<div class="pure-g" style="text-align:right">
<% {"Default", "Music", "Gaming", "Movies", "Livestreams"}.each do |option| %>
<div class="pure-u-1 pure-md-1-3">
<% if trending_type == option %>
<b><%= translate(locale, option) %></b>
<% else %>
<a href="/feed/trending?type=<%= option %>&region=<%= region %>">
<%= translate(locale, option) %>
</a>
<% end %>
</div>
<% end %>
</div>
</div>
</div>
<div class="h-box">
<hr>
</div>
<div class="pure-g">
<% trending.each do |item| %>
<%= rendered "components/item" %>
<% end %>
</div>
<script src="/js/watched_indicator.js"></script>

View File

@ -183,9 +183,9 @@
</div>
<% if env.get?("user") %>
<% feed_options = {"", "Popular", "Trending", "Subscriptions", "Playlists"} %>
<% feed_options = {"", "Popular", "Subscriptions", "Playlists"} %>
<% else %>
<% feed_options = {"", "Popular", "Trending"} %>
<% feed_options = {"", "Popular"} %>
<% end %>
<div class="pure-control-group">