Fix colors and data-url in download widget

pull/334/head
Omar Roth 6 years ago
parent 6218078c51
commit c0fdc28a84

@ -22,11 +22,13 @@ div {
padding-right: 10px; padding-right: 10px;
} }
button.pure-button-primary,
a.pure-button-primary { a.pure-button-primary {
background-color: #a0a0a0; background-color: #a0a0a0;
color: rgba(35, 35, 35, 1); color: rgba(35, 35, 35, 1);
} }
button.pure-button-primary:hover,
a.pure-button-primary:hover { a.pure-button-primary:hover {
background-color: rgba(0, 182, 240, 1); background-color: rgba(0, 182, 240, 1);
color: #fff; color: #fff;
@ -271,14 +273,16 @@ img.thumbnail {
#progress-container { #progress-container {
width: 100%; width: 100%;
border-radius: 2px; border-radius: 2px;
background: #aaa; background-color: #a0a0a0;
color: rgba(35, 35, 35, 1);
} }
#download-progress { #download-progress {
width: 0%; width: 0%;
border-radius: 2px; border-radius: 2px;
height: 10px; height: 10px;
background-color: #0078e7; background-color: rgba(0, 182, 240, 1);
color: #fff;
margin-top: 0.5em; margin-top: 0.5em;
margin-bottom: 0.5em; margin-bottom: 0.5em;
} }

@ -65,8 +65,6 @@ function download_video(target) {
} }
} }
url = "/videoplayback" + url.split("/videoplayback")[1];
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("GET", url); xhr.open("GET", url);
xhr.responseType = "arraybuffer"; xhr.responseType = "arraybuffer";

@ -3658,6 +3658,10 @@ get "/latest_version" do |env|
id = env.params.query["id"]? id = env.params.query["id"]?
itag = env.params.query["itag"]? itag = env.params.query["itag"]?
local = env.params.query["local"]?
local ||= "false"
local = local == "true"
if !id || !itag if !id || !itag
halt env, status_code: 400 halt env, status_code: 400
end end
@ -3674,7 +3678,12 @@ get "/latest_version" do |env|
halt env, status_code: 409 halt env, status_code: 409
end end
env.redirect urls[0]["url"] url = urls[0]["url"]
if local
url = URI.parse(url).full_path.not_nil!
end
env.redirect url
end end
options "/videoplayback" do |env| options "/videoplayback" do |env|

@ -59,13 +59,13 @@
<label for="download_widget"><%= translate(locale, "Download as: ") %></label> <label for="download_widget"><%= translate(locale, "Download as: ") %></label>
<select style="width:100%" name="download_widget" id="download_widget"> <select style="width:100%" name="download_widget" id="download_widget">
<% video_streams.each do |option| %> <% video_streams.each do |option| %>
<option data-url="<%= option["url"] %>"><%= option["quality_label"] %> - <%= option["type"].split(";")[0] %> @ <%= option["fps"] %>fps - video only</option> <option data-url="/latest_version?id=<%= video.id %>&itag=<%= option["itag"] %>&local=true"><%= option["quality_label"] %> - <%= option["type"].split(";")[0] %> @ <%= option["fps"] %>fps - video only</option>
<% end %> <% end %>
<% audio_streams.each do |option| %> <% audio_streams.each do |option| %>
<option data-url="<%= option["url"] %>"><%= option["type"].split(";")[0] %> @ <%= option["bitrate"] %>k - audio only</option> <option data-url="/latest_version?id=<%= video.id %>&itag=<%= option["itag"] %>&local=true"><%= option["type"].split(";")[0] %> @ <%= option["bitrate"] %>k - audio only</option>
<% end %> <% end %>
<% fmt_stream.each do |option| %> <% fmt_stream.each do |option| %>
<option data-url="<%= option["url"] %>"><%= itag_to_metadata?(option["itag"]).try &.["height"]? || "~240" %>p - <%= option["type"].split(";")[0] %></option> <option data-url="/latest_version?id=<%= video.id %>&itag=<%= option["itag"] %>&local=true"><%= itag_to_metadata?(option["itag"]).try &.["height"]? || "~240" %>p - <%= option["type"].split(";")[0] %></option>
<% end %> <% end %>
</select> </select>
</div> </div>
@ -77,7 +77,7 @@
<button type="button" data-title="<%= video.title.dump_unquoted %>-<%= video.id %>.mp4" onclick="download_video(this)" <button type="button" data-title="<%= video.title.dump_unquoted %>-<%= video.id %>.mp4" onclick="download_video(this)"
class="pure-button pure-button-primary"> class="pure-button pure-button-primary">
<%= translate(locale, "Download") %> <b><%= translate(locale, "Download") %></b>
</button> </button>
</form> </form>

Loading…
Cancel
Save