Add fallback for people that used reddit in the comments API and their preferences

This commit is contained in:
Fijxu 2026-10-18 16:03:15 -03:00
parent ba4318b62e
commit 2b02cd1b54
No known key found for this signature in database
GPG Key ID: 32C1DDF333EDA6A4
3 changed files with 31 additions and 0 deletions

View File

@ -50,3 +50,9 @@ class InvalidVideoID < InfoException
return "Invalid video ID '#{id}'" return "Invalid video ID '#{id}'"
end end
end end
class RedditIsDeprecated < InfoException
def message
return "Reddit comments have been removed from Invidious."
end
end

View File

@ -346,6 +346,18 @@ module Invidious::Routes::API::V1::Videos
continuation = env.params.query["continuation"]? continuation = env.params.query["continuation"]?
sort_by = env.params.query["sort_by"]?.try &.downcase 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" if source == "youtube"
sort_by ||= "top" sort_by ||= "top"

View File

@ -74,11 +74,24 @@ module Invidious::Routes::Watch
if nojs if nojs
if preferences if preferences
source = preferences.comments[0] 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? if source.empty?
source = preferences.comments[1] source = preferences.comments[1]
end
if source == "youtube"
comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"] comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"]
end end
else
comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"]
end end
comment_html ||= "" comment_html ||= ""