mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-06-28 01:48:26 +00:00
feat(routes): redirect to the backend selected at the time of downloading
This commit is contained in:
parent
b9114cbb9d
commit
4e2f59ba37
@ -18,14 +18,15 @@ module Invidious::Frontend::WatchPage
|
||||
end
|
||||
end
|
||||
|
||||
def download_widget(locale : String, video : Video, video_assets : VideoAssets) : String
|
||||
def download_widget(locale : String, video : Video, video_assets : VideoAssets, env : HTTP::Server::Context) : String
|
||||
if CONFIG.disabled?("downloads")
|
||||
return "<p id=\"download\">#{translate(locale, "Download is disabled")}</p>"
|
||||
end
|
||||
|
||||
url = "/download"
|
||||
if (CONFIG.invidious_companion.present?)
|
||||
invidious_companion = CONFIG.invidious_companion.sample
|
||||
current_companion = env.get("current_companion").as(Int32)
|
||||
invidious_companion = CONFIG.invidious_companion[current_companion]
|
||||
url = "#{invidious_companion.public_url}/download?check=#{invidious_companion_encrypt(video.id)}"
|
||||
end
|
||||
|
||||
|
@ -312,7 +312,9 @@ module Invidious::Routes::Watch
|
||||
return error_template(403, "Administrator has disabled this endpoint.")
|
||||
end
|
||||
if CONFIG.invidious_companion.present?
|
||||
return error_template(403, "Downloads should be routed through Companion when present")
|
||||
current_companion = env.get("current_companion").as(Int32)
|
||||
invidious_companion = CONFIG.invidious_companion[current_companion]
|
||||
return env.redirect invidious_companion.public_url
|
||||
end
|
||||
|
||||
title = env.params.body["title"]? || ""
|
||||
|
@ -203,7 +203,7 @@ we're going to need to do it here in order to allow for translations.
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= Invidious::Frontend::WatchPage.download_widget(locale, video, video_assets) %>
|
||||
<%= Invidious::Frontend::WatchPage.download_widget(locale, video, video_assets, env) %>
|
||||
|
||||
<p id="views"><i class="icon ion-ios-eye"></i> <%= number_with_separator(video.views) %></p>
|
||||
<p id="likes"><i class="icon ion-ios-thumbs-up"></i> <%= number_with_separator(video.likes) %></p>
|
||||
|
Loading…
Reference in New Issue
Block a user