forked from midou/invidious
Respect DEFAULT_USER_PREFERENCES in video params
This commit is contained in:
parent
fbb5df0849
commit
c9bc081f8c
@ -1128,21 +1128,21 @@ post "/preferences" do |env|
|
|||||||
listen = listen == "on"
|
listen = listen == "on"
|
||||||
|
|
||||||
speed = env.params.body["speed"]?.try &.as(String).to_f?
|
speed = env.params.body["speed"]?.try &.as(String).to_f?
|
||||||
speed ||= 1.0
|
speed ||= DEFAULT_USER_PREFERENCES.speed
|
||||||
|
|
||||||
quality = env.params.body["quality"]?.try &.as(String)
|
quality = env.params.body["quality"]?.try &.as(String)
|
||||||
quality ||= "hd720"
|
quality ||= DEFAULT_USER_PREFERENCES.quality
|
||||||
|
|
||||||
volume = env.params.body["volume"]?.try &.as(String).to_i?
|
volume = env.params.body["volume"]?.try &.as(String).to_i?
|
||||||
volume ||= 100
|
volume ||= DEFAULT_USER_PREFERENCES.volume
|
||||||
|
|
||||||
comments_0 = env.params.body["comments_0"]?.try &.as(String) || "youtube"
|
comments_0 = env.params.body["comments_0"]?.try &.as(String) || DEFAULT_USER_PREFERENCES.comments[0]
|
||||||
comments_1 = env.params.body["comments_1"]?.try &.as(String) || ""
|
comments_1 = env.params.body["comments_1"]?.try &.as(String) || DEFAULT_USER_PREFERENCES.comments[1]
|
||||||
comments = [comments_0, comments_1]
|
comments = [comments_0, comments_1]
|
||||||
|
|
||||||
captions_0 = env.params.body["captions_0"]?.try &.as(String) || ""
|
captions_0 = env.params.body["captions_0"]?.try &.as(String) || DEFAULT_USER_PREFERENCES.captions[0]
|
||||||
captions_1 = env.params.body["captions_1"]?.try &.as(String) || ""
|
captions_1 = env.params.body["captions_1"]?.try &.as(String) || DEFAULT_USER_PREFERENCES.captions[1]
|
||||||
captions_2 = env.params.body["captions_2"]?.try &.as(String) || ""
|
captions_2 = env.params.body["captions_2"]?.try &.as(String) || DEFAULT_USER_PREFERENCES.captions[2]
|
||||||
captions = [captions_0, captions_1, captions_2]
|
captions = [captions_0, captions_1, captions_2]
|
||||||
|
|
||||||
related_videos = env.params.body["related_videos"]?.try &.as(String)
|
related_videos = env.params.body["related_videos"]?.try &.as(String)
|
||||||
@ -1154,7 +1154,7 @@ post "/preferences" do |env|
|
|||||||
redirect_feed = redirect_feed == "on"
|
redirect_feed = redirect_feed == "on"
|
||||||
|
|
||||||
locale = env.params.body["locale"]?.try &.as(String)
|
locale = env.params.body["locale"]?.try &.as(String)
|
||||||
locale ||= "en-US"
|
locale ||= DEFAULT_USER_PREFERENCES.locale
|
||||||
|
|
||||||
dark_mode = env.params.body["dark_mode"]?.try &.as(String)
|
dark_mode = env.params.body["dark_mode"]?.try &.as(String)
|
||||||
dark_mode ||= "off"
|
dark_mode ||= "off"
|
||||||
@ -1165,10 +1165,10 @@ post "/preferences" do |env|
|
|||||||
thin_mode = thin_mode == "on"
|
thin_mode = thin_mode == "on"
|
||||||
|
|
||||||
max_results = env.params.body["max_results"]?.try &.as(String).to_i?
|
max_results = env.params.body["max_results"]?.try &.as(String).to_i?
|
||||||
max_results ||= 40
|
max_results ||= DEFAULT_USER_PREFERENCES.max_results
|
||||||
|
|
||||||
sort = env.params.body["sort"]?.try &.as(String)
|
sort = env.params.body["sort"]?.try &.as(String)
|
||||||
sort ||= "published"
|
sort ||= DEFAULT_USER_PREFERENCES.sort
|
||||||
|
|
||||||
latest_only = env.params.body["latest_only"]?.try &.as(String)
|
latest_only = env.params.body["latest_only"]?.try &.as(String)
|
||||||
latest_only ||= "off"
|
latest_only ||= "off"
|
||||||
|
@ -79,36 +79,36 @@ class Preferences
|
|||||||
autoplay: Bool,
|
autoplay: Bool,
|
||||||
continue: {
|
continue: {
|
||||||
type: Bool,
|
type: Bool,
|
||||||
default: false,
|
default: DEFAULT_USER_PREFERENCES.continue,
|
||||||
},
|
},
|
||||||
listen: {
|
listen: {
|
||||||
type: Bool,
|
type: Bool,
|
||||||
default: false,
|
default: DEFAULT_USER_PREFERENCES.listen,
|
||||||
},
|
},
|
||||||
speed: Float32,
|
speed: Float32,
|
||||||
quality: String,
|
quality: String,
|
||||||
volume: Int32,
|
volume: Int32,
|
||||||
comments: {
|
comments: {
|
||||||
type: Array(String),
|
type: Array(String),
|
||||||
default: ["youtube", ""],
|
default: DEFAULT_USER_PREFERENCES.comments,
|
||||||
converter: StringToArray,
|
converter: StringToArray,
|
||||||
},
|
},
|
||||||
captions: {
|
captions: {
|
||||||
type: Array(String),
|
type: Array(String),
|
||||||
default: ["", "", ""],
|
default: DEFAULT_USER_PREFERENCES.captions,
|
||||||
},
|
},
|
||||||
redirect_feed: {
|
redirect_feed: {
|
||||||
type: Bool,
|
type: Bool,
|
||||||
default: false,
|
default: DEFAULT_USER_PREFERENCES.redirect_feed,
|
||||||
},
|
},
|
||||||
related_videos: {
|
related_videos: {
|
||||||
type: Bool,
|
type: Bool,
|
||||||
default: true,
|
default: DEFAULT_USER_PREFERENCES.related_videos,
|
||||||
},
|
},
|
||||||
dark_mode: Bool,
|
dark_mode: Bool,
|
||||||
thin_mode: {
|
thin_mode: {
|
||||||
type: Bool,
|
type: Bool,
|
||||||
default: false,
|
default: DEFAULT_USER_PREFERENCES.thin_mode,
|
||||||
},
|
},
|
||||||
max_results: Int32,
|
max_results: Int32,
|
||||||
sort: String,
|
sort: String,
|
||||||
@ -116,11 +116,11 @@ class Preferences
|
|||||||
unseen_only: Bool,
|
unseen_only: Bool,
|
||||||
notifications_only: {
|
notifications_only: {
|
||||||
type: Bool,
|
type: Bool,
|
||||||
default: false,
|
default: DEFAULT_USER_PREFERENCES.notifications_only,
|
||||||
},
|
},
|
||||||
locale: {
|
locale: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "en-US",
|
default: DEFAULT_USER_PREFERENCES.locale,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -745,14 +745,14 @@ def process_video_params(query, preferences)
|
|||||||
volume ||= preferences.volume
|
volume ||= preferences.volume
|
||||||
end
|
end
|
||||||
|
|
||||||
autoplay ||= 0
|
autoplay ||= DEFAULT_USER_PREFERENCES.autoplay.to_unsafe
|
||||||
continue ||= 0
|
continue ||= DEFAULT_USER_PREFERENCES.continue.to_unsafe
|
||||||
listen ||= 0
|
listen ||= DEFAULT_USER_PREFERENCES.listen.to_unsafe
|
||||||
preferred_captions ||= [] of String
|
preferred_captions ||= DEFAULT_USER_PREFERENCES.captions
|
||||||
quality ||= "hd720"
|
quality ||= DEFAULT_USER_PREFERENCES.quality
|
||||||
speed ||= 1
|
speed ||= DEFAULT_USER_PREFERENCES.speed
|
||||||
video_loop ||= 0
|
video_loop ||= DEFAULT_USER_PREFERENCES.video_loop.to_unsafe
|
||||||
volume ||= 100
|
volume ||= DEFAULT_USER_PREFERENCES.volume
|
||||||
|
|
||||||
autoplay = autoplay == 1
|
autoplay = autoplay == 1
|
||||||
continue = continue == 1
|
continue = continue == 1
|
||||||
|
Loading…
Reference in New Issue
Block a user