From a3a826e52cf163ce57c1ee62618894372947c3bc Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Tue, 7 Aug 2018 13:10:52 -0500 Subject: [PATCH] Add redirect for local DASH urls --- src/invidious.cr | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 6a7561b4..82cdbc2f 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -2535,6 +2535,15 @@ get "/api/v1/search" do |env| response end +get "/api/manifest/dash/id/videoplayback" do |env| + env.redirect "/videoplayback?#{env.params.query}" +end + +get "/api/manifest/dash/id/videoplayback/*" do |env| + puts env.request.path + env.redirect env.request.path.lchop("/api/manifest/dash/id") +end + get "/api/manifest/dash/id/:id" do |env| env.response.headers.add("Access-Control-Allow-Origin", "*") env.response.content_type = "application/dash+xml" @@ -2557,12 +2566,7 @@ get "/api/manifest/dash/id/:id" do |env| url = url.rchop("") if local - if Kemal.config.ssl || CONFIG.https_only - scheme = "https://" - end - scheme ||= "http://" - - url = scheme + env.request.headers["Host"] + URI.parse(url).full_path + url = URI.parse(url).full_path end "#{url}" @@ -2575,13 +2579,7 @@ get "/api/manifest/dash/id/:id" do |env| if local adaptive_fmts.each do |fmt| - if Kemal.config.ssl || CONFIG.https_only - scheme = "https://" - else - scheme = "http://" - end - - fmt["url"] = scheme + env.request.headers["Host"] + URI.parse(fmt["url"]).full_path + fmt["url"] = URI.parse(fmt["url"]).full_path end end