|
|
@ -6,7 +6,7 @@ class User
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
Preferences.from_json(rs.read(String))
|
|
|
|
Preferences.from_json(rs.read(String))
|
|
|
|
rescue ex
|
|
|
|
rescue ex
|
|
|
|
DEFAULT_USER_PREFERENCES
|
|
|
|
Preferences.from_json("{}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -18,7 +18,6 @@ class User
|
|
|
|
email: String,
|
|
|
|
email: String,
|
|
|
|
preferences: {
|
|
|
|
preferences: {
|
|
|
|
type: Preferences,
|
|
|
|
type: Preferences,
|
|
|
|
default: DEFAULT_USER_PREFERENCES,
|
|
|
|
|
|
|
|
converter: PreferencesConverter,
|
|
|
|
converter: PreferencesConverter,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
password: String?,
|
|
|
|
password: String?,
|
|
|
@ -27,30 +26,30 @@ class User
|
|
|
|
})
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_USER_PREFERENCES = Preferences.from_json({
|
|
|
|
DEFAULT_USER_PREFERENCES = Preferences.new(
|
|
|
|
"video_loop" => false,
|
|
|
|
video_loop: false,
|
|
|
|
"autoplay" => false,
|
|
|
|
autoplay: false,
|
|
|
|
"continue" => false,
|
|
|
|
continue: false,
|
|
|
|
"local" => false,
|
|
|
|
local: false,
|
|
|
|
"listen" => false,
|
|
|
|
listen: false,
|
|
|
|
"speed" => 1.0,
|
|
|
|
speed: 1.0_f32,
|
|
|
|
"quality" => "hd720",
|
|
|
|
quality: "hd720",
|
|
|
|
"volume" => 100,
|
|
|
|
volume: 100,
|
|
|
|
"comments" => ["youtube", ""],
|
|
|
|
comments: ["youtube", ""],
|
|
|
|
"captions" => ["", "", ""],
|
|
|
|
captions: ["", "", ""],
|
|
|
|
"related_videos" => true,
|
|
|
|
related_videos: true,
|
|
|
|
"redirect_feed" => false,
|
|
|
|
redirect_feed: false,
|
|
|
|
"locale" => "en-US",
|
|
|
|
locale: "en-US",
|
|
|
|
"dark_mode" => false,
|
|
|
|
dark_mode: false,
|
|
|
|
"thin_mode" => false,
|
|
|
|
thin_mode: false,
|
|
|
|
"max_results" => 40,
|
|
|
|
max_results: 40,
|
|
|
|
"sort" => "published",
|
|
|
|
sort: "published",
|
|
|
|
"latest_only" => false,
|
|
|
|
latest_only: false,
|
|
|
|
"unseen_only" => false,
|
|
|
|
unseen_only: false,
|
|
|
|
"notifications_only" => false,
|
|
|
|
notifications_only: false,
|
|
|
|
}.to_json)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class Preferences
|
|
|
|
struct Preferences
|
|
|
|
module StringToArray
|
|
|
|
module StringToArray
|
|
|
|
def self.to_json(value : Array(String), json : JSON::Builder)
|
|
|
|
def self.to_json(value : Array(String), json : JSON::Builder)
|
|
|
|
json.array do
|
|
|
|
json.array do
|
|
|
@ -74,58 +73,27 @@ class Preferences
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
JSON.mapping({
|
|
|
|
json_mapping({
|
|
|
|
video_loop: Bool,
|
|
|
|
video_loop: {type: Bool, default: DEFAULT_USER_PREFERENCES.video_loop},
|
|
|
|
autoplay: Bool,
|
|
|
|
autoplay: {type: Bool, default: DEFAULT_USER_PREFERENCES.autoplay},
|
|
|
|
continue: {
|
|
|
|
continue: {type: Bool, default: DEFAULT_USER_PREFERENCES.continue},
|
|
|
|
type: Bool,
|
|
|
|
local: {type: Bool, default: DEFAULT_USER_PREFERENCES.local},
|
|
|
|
default: DEFAULT_USER_PREFERENCES.continue,
|
|
|
|
listen: {type: Bool, default: DEFAULT_USER_PREFERENCES.listen},
|
|
|
|
},
|
|
|
|
speed: {type: Float32, default: DEFAULT_USER_PREFERENCES.speed},
|
|
|
|
local: {
|
|
|
|
quality: {type: String, default: DEFAULT_USER_PREFERENCES.quality},
|
|
|
|
type: Bool,
|
|
|
|
volume: {type: Int32, default: DEFAULT_USER_PREFERENCES.volume},
|
|
|
|
default: DEFAULT_USER_PREFERENCES.local,
|
|
|
|
comments: {type: Array(String), default: DEFAULT_USER_PREFERENCES.comments, converter: StringToArray},
|
|
|
|
},
|
|
|
|
captions: {type: Array(String), default: DEFAULT_USER_PREFERENCES.captions, converter: StringToArray},
|
|
|
|
listen: {
|
|
|
|
redirect_feed: {type: Bool, default: DEFAULT_USER_PREFERENCES.redirect_feed},
|
|
|
|
type: Bool,
|
|
|
|
related_videos: {type: Bool, default: DEFAULT_USER_PREFERENCES.related_videos},
|
|
|
|
default: DEFAULT_USER_PREFERENCES.listen,
|
|
|
|
dark_mode: {type: Bool, default: DEFAULT_USER_PREFERENCES.dark_mode},
|
|
|
|
},
|
|
|
|
thin_mode: {type: Bool, default: DEFAULT_USER_PREFERENCES.thin_mode},
|
|
|
|
speed: Float32,
|
|
|
|
max_results: {type: Int32, default: DEFAULT_USER_PREFERENCES.max_results},
|
|
|
|
quality: String,
|
|
|
|
sort: {type: String, default: DEFAULT_USER_PREFERENCES.sort},
|
|
|
|
volume: Int32,
|
|
|
|
latest_only: {type: Bool, default: DEFAULT_USER_PREFERENCES.latest_only},
|
|
|
|
comments: {
|
|
|
|
unseen_only: {type: Bool, default: DEFAULT_USER_PREFERENCES.unseen_only},
|
|
|
|
type: Array(String),
|
|
|
|
notifications_only: {type: Bool, default: DEFAULT_USER_PREFERENCES.notifications_only},
|
|
|
|
default: DEFAULT_USER_PREFERENCES.comments,
|
|
|
|
locale: {type: String, default: DEFAULT_USER_PREFERENCES.locale},
|
|
|
|
converter: StringToArray,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
captions: {
|
|
|
|
|
|
|
|
type: Array(String),
|
|
|
|
|
|
|
|
default: DEFAULT_USER_PREFERENCES.captions,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
redirect_feed: {
|
|
|
|
|
|
|
|
type: Bool,
|
|
|
|
|
|
|
|
default: DEFAULT_USER_PREFERENCES.redirect_feed,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
related_videos: {
|
|
|
|
|
|
|
|
type: Bool,
|
|
|
|
|
|
|
|
default: DEFAULT_USER_PREFERENCES.related_videos,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
dark_mode: Bool,
|
|
|
|
|
|
|
|
thin_mode: {
|
|
|
|
|
|
|
|
type: Bool,
|
|
|
|
|
|
|
|
default: DEFAULT_USER_PREFERENCES.thin_mode,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
max_results: Int32,
|
|
|
|
|
|
|
|
sort: String,
|
|
|
|
|
|
|
|
latest_only: Bool,
|
|
|
|
|
|
|
|
unseen_only: Bool,
|
|
|
|
|
|
|
|
notifications_only: {
|
|
|
|
|
|
|
|
type: Bool,
|
|
|
|
|
|
|
|
default: DEFAULT_USER_PREFERENCES.notifications_only,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
locale: {
|
|
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
|
|
default: DEFAULT_USER_PREFERENCES.locale,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|