mirror of
https://github.com/iv-org/invidious.git
synced 2026-10-24 22:09:13 -05:00
Add fallback for people that used reddit in the comments API and their preferences
This commit is contained in:
parent
ba4318b62e
commit
2b02cd1b54
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
@ -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 ||= ""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user