mirror of
https://github.com/iv-org/invidious.git
synced 2026-10-25 06:19:12 -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}'"
|
return "Invalid video ID '#{id}'"
|
||||||
end
|
end
|
||||||
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"]?
|
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"
|
||||||
|
|
||||||
|
|||||||
@ -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 ||= ""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user