diff --git a/src/invidious/exceptions.cr b/src/invidious/exceptions.cr index 86ce20c25..f433b6c14 100644 --- a/src/invidious/exceptions.cr +++ b/src/invidious/exceptions.cr @@ -50,3 +50,9 @@ class InvalidVideoID < InfoException return "Invalid video ID '#{id}'" end end + +class RedditIsDeprecated < InfoException + def message + return "Reddit comments have been removed from Invidious." + end +end diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr index 6f44ca659..f825167f7 100644 --- a/src/invidious/routes/api/v1/videos.cr +++ b/src/invidious/routes/api/v1/videos.cr @@ -346,6 +346,18 @@ module Invidious::Routes::API::V1::Videos continuation = env.params.query["continuation"]? sort_by = env.params.query["sort_by"]?.try &.downcase + + # 2026-10-18: Make a mechanism to remove unused + # preferences from PREFS cookie of the clients + # when some preferences are changed, like this one + # which is a Reedit comments deprecation that appears + # on preferences. + # + # Fallback for API users that still use Reddit as a source + if source == "reddit" + return error_json(410, RedditIsDeprecated.new) + end + if source == "youtube" sort_by ||= "top" diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr index 8a7d117a1..ca3faebd1 100644 --- a/src/invidious/routes/watch.cr +++ b/src/invidious/routes/watch.cr @@ -74,11 +74,24 @@ module Invidious::Routes::Watch if nojs if preferences source = preferences.comments[0] + # 2026-10-18: Make a mechanism to remove unused + # preferences from PREFS cookie of the clients + # when some preferences are changed, like this one + # which is a Reedit comments deprecation that appears + # on preferences. + # + # Fallback for people that have reddit in their prefs + source = preferences.comments[1] if source == "reddit" if source.empty? source = preferences.comments[1] + end + + if source == "youtube" comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"] end + else + comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"] end comment_html ||= ""