mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-19 04:34:30 -05:00
Add option to listen by default
This commit is contained in:
parent
8794e26e67
commit
e39dec9778
@ -243,10 +243,7 @@ get "/watch" do |env|
|
|||||||
subscriptions ||= [] of String
|
subscriptions ||= [] of String
|
||||||
|
|
||||||
params = process_video_params(env.params.query, preferences)
|
params = process_video_params(env.params.query, preferences)
|
||||||
|
env.params.query.delete_all("listen")
|
||||||
if params[:listen]
|
|
||||||
env.params.query.delete_all("listen")
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
video = get_video(id, PG_DB, proxies)
|
video = get_video(id, PG_DB, proxies)
|
||||||
@ -880,6 +877,10 @@ post "/preferences" do |env|
|
|||||||
autoplay ||= "off"
|
autoplay ||= "off"
|
||||||
autoplay = autoplay == "on"
|
autoplay = autoplay == "on"
|
||||||
|
|
||||||
|
listen = env.params.body["listen"]?.try &.as(String)
|
||||||
|
listen ||= "off"
|
||||||
|
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 ||= 1.0
|
||||||
|
|
||||||
@ -935,6 +936,7 @@ post "/preferences" do |env|
|
|||||||
preferences = {
|
preferences = {
|
||||||
"video_loop" => video_loop,
|
"video_loop" => video_loop,
|
||||||
"autoplay" => autoplay,
|
"autoplay" => autoplay,
|
||||||
|
"listen" => listen,
|
||||||
"speed" => speed,
|
"speed" => speed,
|
||||||
"quality" => quality,
|
"quality" => quality,
|
||||||
"volume" => volume,
|
"volume" => volume,
|
||||||
|
@ -70,10 +70,14 @@ class Preferences
|
|||||||
JSON.mapping({
|
JSON.mapping({
|
||||||
video_loop: Bool,
|
video_loop: Bool,
|
||||||
autoplay: Bool,
|
autoplay: Bool,
|
||||||
speed: Float32,
|
listen: {
|
||||||
quality: String,
|
type: Bool,
|
||||||
volume: Int32,
|
default: false,
|
||||||
comments: {
|
},
|
||||||
|
speed: Float32,
|
||||||
|
quality: String,
|
||||||
|
volume: Int32,
|
||||||
|
comments: {
|
||||||
type: Array(String),
|
type: Array(String),
|
||||||
default: ["youtube", ""],
|
default: ["youtube", ""],
|
||||||
converter: StringToArray,
|
converter: StringToArray,
|
||||||
|
@ -708,6 +708,7 @@ end
|
|||||||
|
|
||||||
def process_video_params(query, preferences)
|
def process_video_params(query, preferences)
|
||||||
autoplay = query["autoplay"]?.try &.to_i?
|
autoplay = query["autoplay"]?.try &.to_i?
|
||||||
|
listen = query["listen"]? && (query["listen"] == "true" || query["listen"] == "1").to_unsafe
|
||||||
preferred_captions = query["subtitles"]?.try &.split(",").map { |a| a.downcase }
|
preferred_captions = query["subtitles"]?.try &.split(",").map { |a| a.downcase }
|
||||||
quality = query["quality"]?
|
quality = query["quality"]?
|
||||||
speed = query["speed"]?.try &.to_f?
|
speed = query["speed"]?.try &.to_f?
|
||||||
@ -716,6 +717,7 @@ def process_video_params(query, preferences)
|
|||||||
|
|
||||||
if preferences
|
if preferences
|
||||||
autoplay ||= preferences.autoplay.to_unsafe
|
autoplay ||= preferences.autoplay.to_unsafe
|
||||||
|
listen ||= preferences.listen.to_unsafe
|
||||||
preferred_captions ||= preferences.captions
|
preferred_captions ||= preferences.captions
|
||||||
quality ||= preferences.quality
|
quality ||= preferences.quality
|
||||||
speed ||= preferences.speed
|
speed ||= preferences.speed
|
||||||
@ -724,6 +726,7 @@ def process_video_params(query, preferences)
|
|||||||
end
|
end
|
||||||
|
|
||||||
autoplay ||= 0
|
autoplay ||= 0
|
||||||
|
listen ||= 0
|
||||||
preferred_captions ||= [] of String
|
preferred_captions ||= [] of String
|
||||||
quality ||= "hd720"
|
quality ||= "hd720"
|
||||||
speed ||= 1
|
speed ||= 1
|
||||||
@ -731,6 +734,7 @@ def process_video_params(query, preferences)
|
|||||||
volume ||= 100
|
volume ||= 100
|
||||||
|
|
||||||
autoplay = autoplay == 1
|
autoplay = autoplay == 1
|
||||||
|
listen = listen == 1
|
||||||
video_loop = video_loop == 1
|
video_loop = video_loop == 1
|
||||||
|
|
||||||
if query["t"]?
|
if query["t"]?
|
||||||
@ -750,11 +754,6 @@ def process_video_params(query, preferences)
|
|||||||
end
|
end
|
||||||
video_end ||= -1
|
video_end ||= -1
|
||||||
|
|
||||||
if query["listen"]? && (query["listen"] == "true" || query["listen"] == "1")
|
|
||||||
listen = true
|
|
||||||
end
|
|
||||||
listen ||= false
|
|
||||||
|
|
||||||
raw = query["raw"]?.try &.to_i?
|
raw = query["raw"]?.try &.to_i?
|
||||||
raw ||= 0
|
raw ||= 0
|
||||||
raw = raw == 1
|
raw = raw == 1
|
||||||
|
@ -23,6 +23,11 @@ function update_value(element) {
|
|||||||
<input name="autoplay" id="autoplay" type="checkbox" <% if user.preferences.autoplay %>checked<% end %>>
|
<input name="autoplay" id="autoplay" type="checkbox" <% if user.preferences.autoplay %>checked<% end %>>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="listen">Listen by default: </label>
|
||||||
|
<input name="listen" id="listen" type="checkbox" <% if user.preferences.listen %>checked<% end %>>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="speed">Default speed: </label>
|
<label for="speed">Default speed: </label>
|
||||||
<select name="speed" id="speed">
|
<select name="speed" id="speed">
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<h1>
|
<h1>
|
||||||
<%= HTML.escape(video.title) %>
|
<%= HTML.escape(video.title) %>
|
||||||
<% if params[:listen] %>
|
<% if params[:listen] %>
|
||||||
<a href="/watch?<%= env.params.query %>">
|
<a href="/watch?<%= env.params.query %>&listen=0">
|
||||||
<i class="icon ion-ios-videocam"></i>
|
<i class="icon ion-ios-videocam"></i>
|
||||||
</a>
|
</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
Loading…
Reference in New Issue
Block a user