diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-04-15 22:57:17 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-04-15 22:57:17 -0500 |
| commit | 830d6fae8e09937b6c0a0dfffc58f46d6be91fd9 (patch) | |
| tree | 22f5509177d913925c9d2c26e5747f6334f7f925 | |
| parent | bc068721abc19885d5317838f820b4fa73fe87f8 (diff) | |
| download | invidious-830d6fae8e09937b6c0a0dfffc58f46d6be91fd9.tar.gz invidious-830d6fae8e09937b6c0a0dfffc58f46d6be91fd9.tar.bz2 invidious-830d6fae8e09937b6c0a0dfffc58f46d6be91fd9.zip | |
Add support for using local links in manifest
| -rw-r--r-- | src/invidious.cr | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index fb405ffd..7e950317 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -540,6 +540,7 @@ get "/api/manifest/dash/id/:id" do |env| env.response.headers.add("Access-Control-Allow-Origin", "*") env.response.content_type = "application/dash+xml" + local = env.params.query["local"]?.try &.== "true" id = env.params.url["id"] yt_client = get_client(youtube_pool) @@ -560,12 +561,18 @@ get "/api/manifest/dash/id/:id" do |env| halt env, status_code: 403 end - signature = false - if adaptive_fmts[0]? && adaptive_fmts[0]["s"]? - signature = true + if local + adaptive_fmts.each do |fmt| + if Kemal.config.ssl + scheme = "https://" + end + scheme ||= "http://" + + fmt["url"] = scheme + env.request.headers["Host"] + URI.parse(fmt["url"]).full_path + end end - if signature + if adaptive_fmts[0]? && adaptive_fmts[0]["s"]? adaptive_fmts.each do |fmt| fmt["url"] += "&signature=" + decrypt_signature(fmt["s"]) end |
