From 4b76b93610e64a63d61d1369fdef9af119852aab Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 11 Nov 2018 11:45:05 -0600 Subject: [PATCH] Add continuous playback --- src/invidious.cr | 5 +++ src/invidious/users.cr | 6 +++- src/invidious/videos.cr | 5 +++ src/invidious/views/preferences.ecr | 5 +++ src/invidious/views/watch.ecr | 49 +++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/invidious.cr b/src/invidious.cr index 04a7d264..82cf5f69 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -965,6 +965,10 @@ post "/preferences" do |env| autoplay ||= "off" autoplay = autoplay == "on" + continue = env.params.body["continue"]?.try &.as(String) + continue ||= "off" + continue = continue == "on" + listen = env.params.body["listen"]?.try &.as(String) listen ||= "off" listen = listen == "on" @@ -1024,6 +1028,7 @@ post "/preferences" do |env| preferences = { "video_loop" => video_loop, "autoplay" => autoplay, + "continue" => continue, "listen" => listen, "speed" => speed, "quality" => quality, diff --git a/src/invidious/users.cr b/src/invidious/users.cr index f8c1c09a..113fa1c2 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -70,7 +70,11 @@ class Preferences JSON.mapping({ video_loop: Bool, autoplay: Bool, - listen: { + continue: { + type: Bool, + default: false, + }, + listen: { type: Bool, default: false, }, diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index a0fb7f22..1f81b3d5 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -730,6 +730,7 @@ end def process_video_params(query, preferences) autoplay = query["autoplay"]?.try &.to_i? + continue = query["continue"]?.try &.to_i? listen = query["listen"]? && (query["listen"] == "true" || query["listen"] == "1").to_unsafe preferred_captions = query["subtitles"]?.try &.split(",").map { |a| a.downcase } quality = query["quality"]? @@ -739,6 +740,7 @@ def process_video_params(query, preferences) if preferences autoplay ||= preferences.autoplay.to_unsafe + continue ||= preferences.continue.to_unsafe listen ||= preferences.listen.to_unsafe preferred_captions ||= preferences.captions quality ||= preferences.quality @@ -748,6 +750,7 @@ def process_video_params(query, preferences) end autoplay ||= 0 + continue ||= 0 listen ||= 0 preferred_captions ||= [] of String quality ||= "hd720" @@ -756,6 +759,7 @@ def process_video_params(query, preferences) volume ||= 100 autoplay = autoplay == 1 + continue = continue == 1 listen = listen == 1 video_loop = video_loop == 1 @@ -786,6 +790,7 @@ def process_video_params(query, preferences) params = { autoplay: autoplay, + continue: continue, controls: controls, listen: listen, preferred_captions: preferred_captions, diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr index 72b1d609..f7da7540 100644 --- a/src/invidious/views/preferences.ecr +++ b/src/invidious/views/preferences.ecr @@ -23,6 +23,11 @@ function update_value(element) { checked<% end %>> +
+ + checked<% end %>> +
+
checked<% end %>> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index f9d98681..ba3692e2 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -140,6 +140,15 @@ <% if !preferences || preferences && preferences.related_videos %>
+ + <% if !plid && !rvs.empty? %> +
+ + checked<% end %>> +
+
+ <% end %> + <% rvs.each do |rv| %> <% if rv.has_key?("id") %> "> @@ -163,6 +172,46 @@