mirror of
https://github.com/iv-org/invidious.git
synced 2026-04-27 16:57:06 -05:00
Merge d4d6fb27ce49776c471dab757da5d675ef56b97d into 264e7c24e96274941e7831178d372c81fabf1f0a
This commit is contained in:
commit
7fb4b37fdf
@ -184,13 +184,35 @@ def error_redirect_helper(env : HTTP::Server::Context)
|
||||
|
||||
locale = env.get("preferences").as(Preferences).locale
|
||||
|
||||
if request_path.starts_with?("/search") || request_path.starts_with?("/watch") ||
|
||||
if request_path.starts_with?("/search") || (is_watch = request_path.starts_with?("/watch")) ||
|
||||
request_path.starts_with?("/channel") || request_path.starts_with?("/playlist?list=PL")
|
||||
next_steps_text = I18n.translate(locale, "next_steps_error_message")
|
||||
refresh = I18n.translate(locale, "next_steps_error_message_refresh")
|
||||
go_to_youtube = I18n.translate(locale, "next_steps_error_message_go_to_youtube")
|
||||
go_to_youtube_embed = I18n.translate(locale, "videoinfo_youTube_embed_link")
|
||||
switch_instance = I18n.translate(locale, "Switch Invidious Instance")
|
||||
|
||||
if is_watch
|
||||
params = URI.parse(env.request.resource).query_params
|
||||
video_id = params.fetch("v", nil)
|
||||
|
||||
if video_id.presence
|
||||
if params.present?
|
||||
new_params = URI::Params.new
|
||||
list = params["list"]?.presence
|
||||
index = params["index"]?.presence
|
||||
if list && index
|
||||
new_params.add("list", list)
|
||||
new_params.add("index", index)
|
||||
embed_link = HTML.escape("https://youtube.com/embed/#{video_id}?#{new_params}")
|
||||
end
|
||||
else
|
||||
embed_link = HTML.escape("https://youtube.com/embed/#{video_id}")
|
||||
end
|
||||
embed_html_element = "(<a rel=\"noopener\" referrerpolicy=\"origin-when-cross-origin\" href=\"#{embed_link}\">#{go_to_youtube_embed}</a>)"
|
||||
end
|
||||
end
|
||||
|
||||
return <<-END_HTML
|
||||
<p style="margin-bottom: 4px;">#{next_steps_text}</p>
|
||||
<ul>
|
||||
@ -202,6 +224,7 @@ def error_redirect_helper(env : HTTP::Server::Context)
|
||||
</li>
|
||||
<li>
|
||||
<a rel="noreferrer noopener" href="https://youtube.com#{env.request.resource}">#{go_to_youtube}</a>
|
||||
#{embed_html_element}
|
||||
</li>
|
||||
</ul>
|
||||
END_HTML
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user