From ab4b5331836eb763b05d7989b3922dac7325a469 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sat, 28 Jul 2018 11:06:48 -0500 Subject: [PATCH] Add shortened video redirect --- src/invidious.cr | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 0b014424..64388e69 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -2296,10 +2296,22 @@ get "/videoplayback*" do |env| end end -# get "/:id" do |env| -# id = env.params.url["id"] -# env.redirect "/watch?v=#{id}" -# end +get "/:id" do |env| + id = env.params.url["id"] + + params = [] of String + env.params.query.each do |k, v| + params << "#{k}=#{v}" + end + params = params.join("&") + + url = "/watch?v=#{id}" + if params + url += "&#{params}" + end + + env.redirect url +end error 404 do |env| error_message = "404 Page not found"