mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-28 17:07:53 +01:00
Add 'raw' and 'quality' options to embedded videos
This commit is contained in:
parent
b965c8a7a4
commit
ac8fb9d8c8
@ -422,6 +422,13 @@ get "/embed/:id" do |env|
|
||||
end
|
||||
listen ||= false
|
||||
|
||||
raw = env.params.query["raw"]? && env.params.query["raw"].to_i
|
||||
raw ||= 0
|
||||
raw = raw == 1
|
||||
|
||||
quality = env.params.query["quality"]? && env.params.query["quality"]
|
||||
quality ||= "hd720"
|
||||
|
||||
autoplay = env.params.query["autoplay"]?.try &.to_i
|
||||
autoplay ||= 0
|
||||
|
||||
@ -472,6 +479,18 @@ get "/embed/:id" do |env|
|
||||
stream["bitrate"] = (stream["bitrate"].to_f64/1000).to_i.to_s
|
||||
end
|
||||
|
||||
if raw
|
||||
url = fmt_stream[0]["url"]
|
||||
|
||||
fmt_stream.each do |fmt|
|
||||
if fmt["label"].split(" - ")[0] == quality
|
||||
url = fmt["url"]
|
||||
end
|
||||
end
|
||||
|
||||
next env.redirect url
|
||||
end
|
||||
|
||||
thumbnail = "https://i.ytimg.com/vi/#{id}/mqdefault.jpg"
|
||||
|
||||
rendered "embed"
|
||||
|
@ -40,7 +40,11 @@ video, #my_video, .video-js, .vjs-default-skin
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% fmt_stream.each_with_index do |fmt, i| %>
|
||||
<% if quality != "hd720" %>
|
||||
<source src="<%= fmt["url"] %>" type='<%= fmt["type"] %>' label="<%= fmt["label"] %>" selected="<%= quality == fmt["label"].split(" - ")[0] %>">
|
||||
<% else %>
|
||||
<source src="<%= fmt["url"] %>" type='<%= fmt["type"] %>' label="<%= fmt["label"] %>" selected="<%= i == 0 ? true : false %>">
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</video>
|
||||
|
Loading…
Reference in New Issue
Block a user