From 6ffdb5d2c811a27bd6d09aeaabcff5a3a3382db5 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Tue, 2 Dec 2025 20:07:05 -0300 Subject: [PATCH] Fix trending page by leaving livestream and gaming trending pages The livestream trending page is now the default. Adds `content_container = special_category_container["gridRenderer"]?` in the `CategoryRendererParser` needed for the gaming trending page. The JSON structure of the gaming trending page looked like this: ```json "contents": { "twoColumnBrowseResultsRenderer": { "tabs": [ { "tabRenderer": { "selected": true, "content": { "sectionListRenderer": { "contents": [ { "itemSectionRenderer": { "contents": [ { "shelfRenderer": { "title": { "runs": [ { "text": "Trending videos" } ] }, "content": { "gridRenderer": { // <- This was added to the CategoryRendererParser "items": [ { "gridVideoRenderer": { "videoId": "sTWztaLjD20", // More video data // ... } } ] } } } } ] } } ] } } } } ] } } ``` Thanks to https://github.com/TeamNewPipe/NewPipeExtractor/blob/ae2755bf715538dbaed028ecb1a0553c1646710d/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/kiosk/YoutubeTrendingGamingVideosExtractor.java#L11-L13 for the `browse_id` and `params` needed for the gaming trending page. --- src/invidious/trending.cr | 17 +++++++++-------- src/invidious/views/feeds/trending.ecr | 2 +- src/invidious/yt_backend/extractors.cr | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/invidious/trending.cr b/src/invidious/trending.cr index e289ed5b..622fe517 100644 --- a/src/invidious/trending.cr +++ b/src/invidious/trending.cr @@ -4,20 +4,21 @@ def fetch_trending(trending_type, region, locale) plid = nil - browse_id = "FEtrending" + browse_id = "" case trending_type.try &.downcase - when "music" - params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D" when "gaming" - params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D" - when "movies" - params = "4gIKGgh0cmFpbGVycw%3D%3D" + browse_id = "UCOpNcN46UbXVtpKMrmU4Abg" + params = "Egh0cmVuZGluZw%3D%3D" when "livestreams" browse_id = "UC4R8DWoMoI7CAwX8_LjQHig" params = "EgdsaXZldGFikgEDCKEK" - else # Default - params = "" + else + # Livestreams is the default one as Youtube removed + # the aggregated trending page + # https://github.com/iv-org/invidious/issues/5397#issuecomment-3218928458 + browse_id = "UC4R8DWoMoI7CAwX8_LjQHig" + params = "EgdsaXZldGFikgEDCKEK" end client_config = YoutubeAPI::ClientConfig.new(region: region) diff --git a/src/invidious/views/feeds/trending.ecr b/src/invidious/views/feeds/trending.ecr index 69483f30..46d02ad4 100644 --- a/src/invidious/views/feeds/trending.ecr +++ b/src/invidious/views/feeds/trending.ecr @@ -21,7 +21,7 @@
- <% {"Default", "Music", "Gaming", "Movies", "Livestreams"}.each do |option| %> + <% {"Livestreams", "Gaming"}.each do |option| %>
<% if trending_type == option %> <%= translate(locale, option) %> diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index 85f6caa5..04e00f20 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -442,6 +442,7 @@ private module Parsers if content_container = special_category_container["horizontalListRenderer"]? elsif content_container = special_category_container["expandedShelfContentsRenderer"]? elsif content_container = special_category_container["verticalListRenderer"]? + elsif content_container = special_category_container["gridRenderer"]? else # Anything else, such as `horizontalMovieListRenderer` is currently unsupported. return