mirror of
https://github.com/iv-org/invidious.git
synced 2025-12-03 20:38:29 -06:00
Merge 3e0878aef26f3793eb380002ec4bfcb42bf4dfb4 into b2ecd8abc3c345642999b7d92b54a6cf241ffdac
This commit is contained in:
commit
9b6d903813
@ -712,12 +712,12 @@ default_user_preferences:
|
|||||||
## when the user is logged in.
|
## when the user is logged in.
|
||||||
##
|
##
|
||||||
## Accepted values: A list of strings
|
## Accepted values: A list of strings
|
||||||
## Each entry can be one of: "Popular", "Trending",
|
## Each entry can be one of: "Popular",
|
||||||
## "Subscriptions", "Playlists"
|
## "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.
|
## Default feed to display on the home page.
|
||||||
@ -725,7 +725,7 @@ default_user_preferences:
|
|||||||
## Note: setting this option to "Popular" has no
|
## Note: setting this option to "Popular" has no
|
||||||
## effect when 'popular_enabled' is set to false.
|
## effect when 'popular_enabled' is set to false.
|
||||||
##
|
##
|
||||||
## Accepted values: Popular, Trending, Subscriptions, Playlists, <none>
|
## Accepted values: Popular, Subscriptions, Playlists, <none>
|
||||||
## Default: Popular
|
## Default: Popular
|
||||||
##
|
##
|
||||||
#default_home: Popular
|
#default_home: Popular
|
||||||
|
|||||||
@ -9,7 +9,6 @@ require "../src/invidious/videos/caption"
|
|||||||
require "../src/invidious/videos"
|
require "../src/invidious/videos"
|
||||||
require "../src/invidious/playlists"
|
require "../src/invidious/playlists"
|
||||||
require "../src/invidious/search/ctoken"
|
require "../src/invidious/search/ctoken"
|
||||||
require "../src/invidious/trending"
|
|
||||||
require "spectator"
|
require "spectator"
|
||||||
|
|
||||||
Spectator.configure do |config|
|
Spectator.configure do |config|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ struct ConfigPreferences
|
|||||||
property quality : String = "dash"
|
property quality : String = "dash"
|
||||||
property quality_dash : String = "auto"
|
property quality_dash : String = "auto"
|
||||||
property default_home : String? = "Popular"
|
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 automatic_instance_redirect : Bool = false
|
||||||
property region : String = "US"
|
property region : String = "US"
|
||||||
property related_videos : Bool = true
|
property related_videos : Bool = true
|
||||||
|
|||||||
@ -1,29 +1,4 @@
|
|||||||
module Invidious::Routes::API::V1::Feeds
|
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)
|
def self.popular(env)
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
|
||||||
|
|||||||
@ -42,24 +42,6 @@ module Invidious::Routes::Feeds
|
|||||||
end
|
end
|
||||||
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)
|
def self.subscriptions(env)
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
locale = env.get("preferences").as(Preferences).locale
|
||||||
|
|
||||||
|
|||||||
@ -9,8 +9,6 @@ module Invidious::Routes::Misc
|
|||||||
case preferences.default_home
|
case preferences.default_home
|
||||||
when "Popular"
|
when "Popular"
|
||||||
env.redirect "/feed/popular"
|
env.redirect "/feed/popular"
|
||||||
when "Trending"
|
|
||||||
env.redirect "/feed/trending"
|
|
||||||
when "Subscriptions"
|
when "Subscriptions"
|
||||||
if user
|
if user
|
||||||
env.redirect "/feed/subscriptions"
|
env.redirect "/feed/subscriptions"
|
||||||
|
|||||||
@ -103,7 +103,7 @@ module Invidious::Routes::PreferencesRoute
|
|||||||
default_home = env.params.body["default_home"]?.try &.as(String) || CONFIG.default_user_preferences.default_home
|
default_home = env.params.body["default_home"]?.try &.as(String) || CONFIG.default_user_preferences.default_home
|
||||||
|
|
||||||
feed_menu = [] of String
|
feed_menu = [] of String
|
||||||
4.times do |index|
|
3.times do |index|
|
||||||
option = env.params.body["feed_menu[#{index}]"]?.try &.as(String) || ""
|
option = env.params.body["feed_menu[#{index}]"]?.try &.as(String) || ""
|
||||||
if !option.empty?
|
if !option.empty?
|
||||||
feed_menu << option
|
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
|
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
|
admin_feed_menu = [] of String
|
||||||
4.times do |index|
|
3.times do |index|
|
||||||
option = env.params.body["admin_feed_menu[#{index}]"]?.try &.as(String) || ""
|
option = env.params.body["admin_feed_menu[#{index}]"]?.try &.as(String) || ""
|
||||||
if !option.empty?
|
if !option.empty?
|
||||||
admin_feed_menu << option
|
admin_feed_menu << option
|
||||||
|
|||||||
@ -98,7 +98,6 @@ module Invidious::Routing
|
|||||||
get "/view_all_playlists", Routes::Feeds, :view_all_playlists_redirect
|
get "/view_all_playlists", Routes::Feeds, :view_all_playlists_redirect
|
||||||
get "/feed/playlists", Routes::Feeds, :playlists
|
get "/feed/playlists", Routes::Feeds, :playlists
|
||||||
get "/feed/popular", Routes::Feeds, :popular
|
get "/feed/popular", Routes::Feeds, :popular
|
||||||
get "/feed/trending", Routes::Feeds, :trending
|
|
||||||
get "/feed/subscriptions", Routes::Feeds, :subscriptions
|
get "/feed/subscriptions", Routes::Feeds, :subscriptions
|
||||||
get "/feed/history", Routes::Feeds, :history
|
get "/feed/history", Routes::Feeds, :history
|
||||||
|
|
||||||
@ -249,7 +248,6 @@ module Invidious::Routing
|
|||||||
get "/api/v1/transcripts/:id", {{namespace}}::Videos, :transcripts
|
get "/api/v1/transcripts/:id", {{namespace}}::Videos, :transcripts
|
||||||
|
|
||||||
# Feeds
|
# Feeds
|
||||||
get "/api/v1/trending", {{namespace}}::Feeds, :trending
|
|
||||||
get "/api/v1/popular", {{namespace}}::Feeds, :popular
|
get "/api/v1/popular", {{namespace}}::Feeds, :popular
|
||||||
|
|
||||||
# Channels
|
# Channels
|
||||||
|
|||||||
@ -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
|
|
||||||
@ -1,5 +1,12 @@
|
|||||||
<div class="feed-menu">
|
<div class="feed-menu">
|
||||||
<% feed_menu = env.get("preferences").as(Preferences).feed_menu.dup %>
|
<% 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") %>
|
<% if !env.get?("user") %>
|
||||||
<% feed_menu.reject! {|item| {"Subscriptions", "Playlists"}.includes? item} %>
|
<% feed_menu.reject! {|item| {"Subscriptions", "Playlists"}.includes? item} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -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 %>®ion=<%= 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>
|
|
||||||
@ -183,9 +183,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if env.get?("user") %>
|
<% if env.get?("user") %>
|
||||||
<% feed_options = {"", "Popular", "Trending", "Subscriptions", "Playlists"} %>
|
<% feed_options = {"", "Popular", "Subscriptions", "Playlists"} %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% feed_options = {"", "Popular", "Trending"} %>
|
<% feed_options = {"", "Popular"} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user