diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr index e2c4b650..660c1994 100644 --- a/src/invidious/helpers/errors.cr +++ b/src/invidious/helpers/errors.cr @@ -184,13 +184,29 @@ 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 = translate(locale, "next_steps_error_message") refresh = translate(locale, "next_steps_error_message_refresh") go_to_youtube = translate(locale, "next_steps_error_message_go_to_youtube") + go_to_youtube_embed = translate(locale, "videoinfo_youTube_embed_link") switch_instance = 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 + params.delete("v") + if params.present? + embed_link = "https://youtube.com/embed/#{video_id}?#{params}" + else + embed_link = "https://youtube.com/embed/#{video_id}" + end + embed_html_element = "(#{go_to_youtube_embed})" + end + end + return <<-END_HTML

#{next_steps_text}

END_HTML