feat(routes): redirect to the backend selected at the time of downloading

This commit is contained in:
Fijxu
2025-05-08 00:44:36 -04:00
parent b9114cbb9d
commit 4e2f59ba37
3 changed files with 7 additions and 4 deletions

View File

@@ -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