mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Add 'continue_autoplay' preference
This commit is contained in:
parent
eac0a52f10
commit
bb5a1ad513
7 changed files with 40 additions and 23 deletions
|
@ -1241,6 +1241,10 @@ post "/preferences" do |env|
|
|||
continue ||= "off"
|
||||
continue = continue == "on"
|
||||
|
||||
continue_autoplay = env.params.body["continue_autoplay"]?.try &.as(String)
|
||||
continue_autoplay ||= "off"
|
||||
continue_autoplay = continue_autoplay == "on"
|
||||
|
||||
listen = env.params.body["listen"]?.try &.as(String)
|
||||
listen ||= "off"
|
||||
listen = listen == "on"
|
||||
|
@ -1309,6 +1313,7 @@ post "/preferences" do |env|
|
|||
"video_loop" => video_loop,
|
||||
"autoplay" => autoplay,
|
||||
"continue" => continue,
|
||||
"continue_autoplay" => continue_autoplay,
|
||||
"listen" => listen,
|
||||
"local" => local,
|
||||
"speed" => speed,
|
||||
|
|
|
@ -63,6 +63,7 @@ struct ConfigPreferences
|
|||
captions: {type: Array(String), default: ["", "", ""], converter: StringToArray},
|
||||
comments: {type: Array(String), default: ["youtube", ""], converter: StringToArray},
|
||||
continue: {type: Bool, default: false},
|
||||
continue_autoplay: {type: Bool, default: true},
|
||||
dark_mode: {type: Bool, default: false},
|
||||
latest_only: {type: Bool, default: false},
|
||||
listen: {type: Bool, default: false},
|
||||
|
|
|
@ -88,6 +88,7 @@ struct Preferences
|
|||
captions: {type: Array(String), default: CONFIG.default_user_preferences.captions, converter: StringToArray},
|
||||
comments: {type: Array(String), default: CONFIG.default_user_preferences.comments, converter: StringToArray},
|
||||
continue: {type: Bool, default: CONFIG.default_user_preferences.continue},
|
||||
continue_autoplay: {type: Bool, default: CONFIG.default_user_preferences.continue_autoplay},
|
||||
dark_mode: {type: Bool, default: CONFIG.default_user_preferences.dark_mode},
|
||||
latest_only: {type: Bool, default: CONFIG.default_user_preferences.latest_only},
|
||||
listen: {type: Bool, default: CONFIG.default_user_preferences.listen},
|
||||
|
|
|
@ -1017,6 +1017,7 @@ end
|
|||
def process_video_params(query, preferences)
|
||||
autoplay = query["autoplay"]?.try &.to_i?
|
||||
continue = query["continue"]?.try &.to_i?
|
||||
continue_autoplay = query["continue_autoplay"]?.try &.to_i?
|
||||
listen = query["listen"]? && (query["listen"] == "true" || query["listen"] == "1").to_unsafe
|
||||
local = query["local"]? && (query["local"] == "true").to_unsafe
|
||||
preferred_captions = query["subtitles"]?.try &.split(",").map { |a| a.downcase }
|
||||
|
@ -1031,6 +1032,7 @@ def process_video_params(query, preferences)
|
|||
# region ||= preferences.region
|
||||
autoplay ||= preferences.autoplay.to_unsafe
|
||||
continue ||= preferences.continue.to_unsafe
|
||||
continue_autoplay ||= preferences.continue_autoplay.to_unsafe
|
||||
listen ||= preferences.listen.to_unsafe
|
||||
local ||= preferences.local.to_unsafe
|
||||
preferred_captions ||= preferences.captions
|
||||
|
@ -1043,6 +1045,7 @@ def process_video_params(query, preferences)
|
|||
|
||||
autoplay ||= CONFIG.default_user_preferences.autoplay.to_unsafe
|
||||
continue ||= CONFIG.default_user_preferences.continue.to_unsafe
|
||||
continue_autoplay ||= CONFIG.default_user_preferences.continue_autoplay.to_unsafe
|
||||
listen ||= CONFIG.default_user_preferences.listen.to_unsafe
|
||||
local ||= CONFIG.default_user_preferences.local.to_unsafe
|
||||
preferred_captions ||= CONFIG.default_user_preferences.captions
|
||||
|
@ -1054,6 +1057,7 @@ def process_video_params(query, preferences)
|
|||
|
||||
autoplay = autoplay == 1
|
||||
continue = continue == 1
|
||||
continue_autoplay = continue_autoplay == 1
|
||||
listen = listen == 1
|
||||
local = local == 1
|
||||
related_videos = related_videos == 1
|
||||
|
@ -1087,6 +1091,7 @@ def process_video_params(query, preferences)
|
|||
params = {
|
||||
autoplay: autoplay,
|
||||
continue: continue,
|
||||
continue_autoplay: continue_autoplay,
|
||||
controls: controls,
|
||||
listen: listen,
|
||||
local: local,
|
||||
|
|
|
@ -55,13 +55,13 @@ function get_playlist(timeouts = 0) {
|
|||
location.assign("/embed/"
|
||||
+ xhr.response.nextVideo
|
||||
+ "?list=<%= plid %>"
|
||||
<% if params[:listen] %>
|
||||
+ "&listen=1"
|
||||
<% if params[:listen] != preferences.listen %>
|
||||
+ "&listen=<%= params[:listen] %>"
|
||||
<% end %>
|
||||
<% if params[:autoplay] %>
|
||||
<% if params[:autoplay] || params[:continue_autoplay] %>
|
||||
+ "&autoplay=1"
|
||||
<% end %>
|
||||
<% if params[:speed] %>
|
||||
<% if params[:speed] != preferences.speed %>
|
||||
+ "&speed=<%= params[:speed] %>"
|
||||
<% end %>
|
||||
);
|
||||
|
@ -85,13 +85,13 @@ player.on('ended', function() {
|
|||
<% if !video_series.empty? %>
|
||||
+ "?playlist=<%= video_series.join(",") %>"
|
||||
<% end %>
|
||||
<% if params[:listen] %>
|
||||
+ "&listen=1"
|
||||
<% if params[:listen] != preferences.listen %>
|
||||
+ "&listen=<%= params[:listen] %>"
|
||||
<% end %>
|
||||
<% if params[:autoplay] %>
|
||||
<% if params[:autoplay] || params[:continue_autoplay] %>
|
||||
+ "&autoplay=1"
|
||||
<% end %>
|
||||
<% if params[:speed] %>
|
||||
<% if params[:speed] != preferences.speed %>
|
||||
+ "&speed=<%= params[:speed] %>"
|
||||
<% end %>
|
||||
);
|
||||
|
|
|
@ -24,10 +24,15 @@ function update_value(element) {
|
|||
</div>
|
||||
|
||||
<div class="pure-control-group">
|
||||
<label for="continue"><%= translate(locale, "Autoplay next video: ") %></label>
|
||||
<label for="continue"><%= translate(locale, "Play next by default: ") %></label>
|
||||
<input name="continue" id="continue" type="checkbox" <% if preferences.continue %>checked<% end %>>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group">
|
||||
<label for="continue_autoplay"><%= translate(locale, "Autoplay next video: ") %></label>
|
||||
<input name="continue_autoplay" id="continue_autoplay" type="checkbox" <% if preferences.continue_autoplay %>checked<% end %>>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group">
|
||||
<label for="local"><%= translate(locale, "Proxy videos? ") %></label>
|
||||
<input name="local" id="local" type="checkbox" <% if preferences.local %>checked<% end %>>
|
||||
|
|
|
@ -202,13 +202,13 @@ player.on('ended', function() {
|
|||
location.assign("/watch?v="
|
||||
+ "<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>"
|
||||
+ "&continue=1"
|
||||
<% if params[:listen] %>
|
||||
+ "&listen=1"
|
||||
<% if params[:listen] != preferences.listen %>
|
||||
+ "&listen=<%= params[:listen] %>"
|
||||
<% end %>
|
||||
<% if params[:autoplay] %>
|
||||
<% if params[:autoplay] || params[:continue_autoplay] %>
|
||||
+ "&autoplay=1"
|
||||
<% end %>
|
||||
<% if params[:speed] %>
|
||||
<% if params[:speed] != preferences.speed %>
|
||||
+ "&speed=<%= params[:speed] %>"
|
||||
<% end %>
|
||||
);
|
||||
|
@ -221,13 +221,13 @@ function continue_autoplay(target) {
|
|||
location.assign("/watch?v="
|
||||
+ "<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>"
|
||||
+ "&continue=1"
|
||||
<% if params[:listen] %>
|
||||
+ "&listen=1"
|
||||
<% if params[:listen] != preferences.listen %>
|
||||
+ "&listen=<%= params[:listen] %>"
|
||||
<% end %>
|
||||
<% if params[:autoplay] %>
|
||||
<% if params[:autoplay] || params[:continue_autoplay] %>
|
||||
+ "&autoplay=1"
|
||||
<% end %>
|
||||
<% if params[:speed] %>
|
||||
<% if params[:speed] != preferences.speed %>
|
||||
+ "&speed=<%= params[:speed] %>"
|
||||
<% end %>
|
||||
);
|
||||
|
@ -287,13 +287,13 @@ function get_playlist(timeouts = 0) {
|
|||
location.assign("/watch?v="
|
||||
+ xhr.response.nextVideo
|
||||
+ "&list=<%= plid %>"
|
||||
<% if params[:listen] %>
|
||||
+ "&listen=1"
|
||||
<% if params[:listen] != preferences.listen %>
|
||||
+ "&listen=<%= params[:listen] %>"
|
||||
<% end %>
|
||||
<% if params[:autoplay] %>
|
||||
<% if params[:autoplay] || params[:continue_autoplay] %>
|
||||
+ "&autoplay=1"
|
||||
<% end %>
|
||||
<% if params[:speed] %>
|
||||
<% if params[:speed] != preferences.speed %>
|
||||
+ "&speed=<%= params[:speed] %>"
|
||||
<% end %>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue